Скачать презентацию topic 5 Windows and Frames Goals and Скачать презентацию topic 5 Windows and Frames Goals and

59a3a3b5b8562b719c9dad8d537ef680.ppt

  • Количество слайдов: 18

topic 5 Windows and Frames topic 5 Windows and Frames

Goals and Objectives n Goals Understand Java. Script window object, how popup windows work, Goals and Objectives n Goals Understand Java. Script window object, how popup windows work, find the browser that a client is using, how to use DHTML, and understand the relationship between frames and windows n Objectives n n n n Windows and frames Browser object Location object History object Window object Frames DHTML Practice using the window and other objects 2

Chapter Headlines n n 1 Introduction n Learn the secrets behind all these ad Chapter Headlines n n 1 Introduction n Learn the secrets behind all these ad popups 2 Browser Object n Find out which browser a client is using 3 Location Object n Control 7 Including Java. Script files n Learn how to load and use library files 8 DHTML n Find out what the “D” in DHTML means 3

Introduction n n n When browsing, many other windows pop up Closing these windows Introduction n n n When browsing, many other windows pop up Closing these windows gives rise to others This attracts the attention of web surfers Different browsers are often incompatible Web sites optimize their web pages for a particular browser Java. Script makes all of this easy to accomplish Java. Script provides objects with properties and behaviors for these actions 4

Browser Object n n Java. Script browser related objects are: navigator, Mime. Type, and Browser Object n n Java. Script browser related objects are: navigator, Mime. Type, and Plugin Properties of navigator object: app. Code. Name, app. Version, language, mime. Type, platform, plugins, user. Agent n Methods of navigator object: java. Enabled(), preference(), taint. Enabled() 5

Browser Object n Example 23. 1: Use navigator object 6 Browser Object n Example 23. 1: Use navigator object 6

Location Object n n Location object represents the URL associated with a window object Location Object n n Location object represents the URL associated with a window object Properties of Location object: hash, hostname, href, pathname, port, protocol, search n Methods of Location object: reload(), replace(), 7

Location Object n Example 23. 2: Use Location object 8 Location Object n Example 23. 2: Use Location object 8

History Object n History object contains the URLs that the client has n visited History Object n History object contains the URLs that the client has n visited during a browser session Properties of History object: length, current, next, previous n Methods of Location object: back(), forward(), go(x) 9

History Object n Example 23. 3: Use History object 10 History Object n Example 23. 3: Use History object 10

Window Object n window object is the root object in Java. Script DOM tree Window Object n window object is the root object in Java. Script DOM tree n We can refer to the current window in three ways: window, self, top n Properties of window object: closed, default. Status, document, frames, history, inner. Height, inner. Width, length, locationbar, menubar, name, opener, outer. Height, outer. Width, page. XOffset, page. YOffset, parent, personalbar, scrollbars, self, statusbar, toolbar, top, window n Methods of window object: alert(), back(), blur(x), capture. Events(), clear. Interval(), clear. Timeout(), close(), confirm(), find(), focus(), forward(), home, move. By(), open(), print(), resize. By(), etc. 11

Window Object n Example 23. 4: Create and ad popup window 12 Window Object n Example 23. 4: Create and ad popup window 12

Frame Object n n n A frame set displays multiple frames each with its Frame Object n n n A frame set displays multiple frames each with its own URL Java. Script does not use tree structure to simplify dealing with nesting frames Java. Script creates an array called frames that holds all the frames of a frame set Java. Script represents a frame using a window object Example: frames[0]. document is the first frame declared frames[1]. document is the second frame declared frames[2]. document is the third frame declared 13

Frame Object n Example 23. 6: Use frames 14 Frame Object n Example 23. 6: Use frames 14

Including Java. Script Files n n n Java. Script can load and use files Including Java. Script Files n n n Java. Script can load and use files stored in libraries Functions can be stored in their own files and can be loaded at run-time The benefits are: Simplifies the HTML files of web pages n Makes one function usable by more than one web page n Provides a central location to change a function n The file extensions are. js example my. Lib. js n These files are accessed using the src attribute of the