Объекты в JavaScript Лекция. 2 Объект window Свойства: name document location status top parent frame frames.

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

Developing Database-resident Help for Customizable Web-based Applications Scott DeLoach.
Tutorial 5 Windows and Frames Section A - Working with Windows.
Copyright ©2005 Department of Computer & Information Science Advanced DHTML & DOM: Working with the Window Object.
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
Lesson 8 Cookies. What is a cookie A little “tarball” of information stored on the client machine’s hard drive. –Usually in the cookies.txt file –information.
What we learned in last lesson How to add JavaScript to your HTML pages How to use dialog boxes and variables to store and utilize user input How to write.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Web Basics ISYS546. Basic Tools Web server –Default directory, default home page –Virtual directory Web page editor –Front Page Web page languages –HTML,
Javascript Document Object Model. How to use JavaScript  JavaScript can be embedded into your html pages in a couple of ways  in elements in both and.
Information Technology Center Hany Abdelwahab Computer Specialist.
AdvWeb-1/14 DePaul University SNL 262 Advanced Web Page Design Chapt 10 - Document/location/navigator Objects - Instructor: David A. Lash.
JavaScript ICW: Lecture 11 Tom Chothia. Last Lecture URLs Threads, to make a process run in parallel: Make it extend Thread Give it a run method Call.
The Browser Object Model (BOM) The API of JavaScript’s browser host environment SE-2840 Dr. Mark L. Hornick 1.
JavaScript - Document Object Model. Bhawna Mallick 2 Unit Plan What is DOM and its use? Hierarchy of DOM objects. Reflection of these objects in an HTML.
Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Unobtrusive JavaScript
Chapter 8 OBJECT-ORIENTED TECHNOLOGIES AND DSS DESIGN Decision Support Systems For Business Intelligence.
1 Учебный курс Введение в JavaScript и CGI Лекция 4 Работа с графикой, гипертекстовые переходы и синтаксис языка кандидат технических наук Павел Брониславович.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
History, Navigator, Screen and Form Objects Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
CSE 154 LECTURE 19: EVENTS AND TIMERS. Anonymous functions function(parameters) { statements; } JS JavaScript allows you to declare anonymous functions.
Java Script This is a first JavaScript example. This is a first JavaScript example.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
JAVASCRIPT QUIZ BOWL By: Joseph Lindo. Quiz Bowl Mechanics  Group w/ 5 maximum members  Question is presented at the board  Prepare piece of papers.
Project 9: Exploring the Document Object Essentials for Design JavaScript Level One Michael Brooks.
Tutorial 5 Windows and Frames Section B - Working with Frames and Other Objects Go to Other Objects.
Chapter 5: Windows and Frames
Navigator, Windows and Frames
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Window Object.
Variety of JavaScript Examples Please use speaker notes for additional information!
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
Introduction to JavaScript Objects, Properties, Methods.
JavaScript DOM.
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
Cookies (continue). Extracting Data From Cookies Data retrieved from a cookie is a simple text string. While there is no specific JavaScript function.
JavaScript, Part 4 Instructor: Charles Moen CSCI/CINF 4230.
© 2007 D. J. ForemanJS-1 A Light Introduction for Non-programmers JavaScript for Beginners.
Chapter 12: Objects CIS 275—Web Application Development for Business I.
OBJECTS What is an Object? Definition Properties Methods Events.
Topic 5 Windows and Frames. 2 Goals and Objectives Goals Goals Understand JavaScript window object, how popup windows work, find the browser that a client.
IS2802 Introduction to Multimedia Applications for Business Lecture 8: JavaScript and Cookies Rob Gleasure
Project 5: Using Pop-Up Windows Essentials for Design JavaScript Level One Michael Brooks.
Java Script This is a first JavaScript example. This is a first JavaScript example.
Working with the Window Object JavaScript considers the browser window an object, which it calls the window object.
Adding Javascript How to include javascript in a webpage.
JavaScript and Ajax (JavaScript window object) Week 6 Web site:
CNIT 133 Interactive Web Pags – JavaScript and AJAX Popup Boxes.
20-753: Fundamentals of Web Programming 1 Lecture 13: Javascript II Fundamentals of Web Programming Lecture 13: Javascript II.
Chapter 4 Java Script – Part2. 2 Location object Properties Properties href – whole path will be displayed. ex: window.location.href ( see example 11)
Programming With JavaScript
JavaScript and HTML Simple Event Handling 11-May-18.
Applied Component I Unit II Introduction of java-script
In this session, you will learn to:
Programming the Web using XHTML and JavaScript
JavaScript for Beginners
14-мавзу. Cookie, сеанс, FTP и технологиялари
JavaScript and HTML Simple Event Handling 19-Sep-18.
Javascript الجافا سكربت هي لغة برمجه اذا جاز التعبیر تلعب دور حیوي وفعال في صفحات الویب من خلال القیام بوظائف قد تكون خارجیة او داخلیة بل لنكن اكثر دقة.
برمجة صفحات إنترنت (JavaScript )
Making web pages interactive with JavaScript
Windows The Window Objects.
More JavaScript.
JavaScript for Beginners
JavaScript for Beginners
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript: BOM and DOM CS Programming Languages for Web Applications
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

Объекты в JavaScript Лекция

2 Объект window Свойства: name document location status top parent frame frames

3 Объект window Метод open window.open("URL", "windowName" ("windowFeatures") newWindow=window.open ("URL", "Window_name" [,"windowFeatures"]) windowFeatures: toolbar location directories status menubar scrollbars resizable width height window.open("ya.ru", "windowName", toolbar=yes,location=yes,directories=no,status=yes, menubar=no,scrollbars=yes, resizable=yes");

4 Объект window Методы: close window.сlose(); windowName.close(); alert [window.]alert (Message); confirm if (confirm("Перейти?") ) win1 = window.open(" prompt [window.]prompt(message[, inputDefault]) var userName = prompt("Введите имя", ""); setTimeout clearTimeout

5 Объект window var timerID = null; var timerRunning = false; function startclock () { stopclock(); showtime(); } function showtime() { var now = new Date(); clock.display.value = now.toLocaleString(); timerID = setTimeout("startclock()",1000); timerRunning = true; } function stopclock () { if(timerRunning) clearTimeout(timerID); timerRunning=false; }

6 Объект document Свойства: alinkColor bgСolor fgColor linkСolor vlinkColor lastModified location referrer title Методы: write writeln clear close open

7 Объект location Свойства: href protocol hostname port host pathname hash search

8 Объект history Свойства: length Методы: back forward go

9 Объект navigator Свойства: appName appCodeName appVersion

10 Пример 1. Смена картинок. Изменение картинки при выборе гиперссылки function l_image(a) { document.images[0].src=a; } рисунок 1 рисунок 2 рисунок 3

11 Пример 2. Смена картинок 2. Мультипликация по событию onLoad pictures = new Array(); for(i=0;i<3;i++){ pictures[i] = new Image(); if(i==0) pictures[i].src = "/pictures/it/javascript/3.gif"; if(i==1) pictures[i].src = "/pictures/it/javascript/2.gif"; if(i==2) pictures[i].src = "/pictures/it/javascript/1.gif";} n=1; flag=1; function scroll_image(){ if(flag==1){ n++;if(n>2) n=0; document.images[0].src = pictures[n].src;} setTimeout("scroll_image()",1500); } <body bgcolor="#FFF5EE" text="#000000" link="#FF0000" alink="#FF0000" vlink="#A52A2A" onLoad=scroll_image()>

12 Пример 3. Персонализация пользователя. var username = GetCookie('username'); if (username == null) { username = prompt('Пожалуйста, введите Ваше имя\n(в противном случае нажмите cancel)',""); if (username == null) { username = 'Без имени'; } else { pathname = location.pathname; myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/'; // Установка параметра expire на год вперед. var largeExpDate = new Date (); largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000)); SetCookie('username',username,largeExpDate,myDomain); }} function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null;}

13 Пример 4. Персонализация пользователя. function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } document.write(' Здравствуйте, ' + username + ' ');

Объекты в JavaScript Раздел: Технологии создания сайтов