Download presentation
Presentation is loading. Please wait.
1
Windows The Window Objects
2
Creating a New Window OR...how to annoy your Web site visitors with annoying ads. myWin = window.open("URL", "Name", "Features"); myWin = window.open("new.htm", "Fred", "width=200, height=200, toolbar=0, status=0"); NOTICE THE FEATURES ARE ALL ACTUALLY ONE PARAMETER THAT JAVASCRIPT INTERPRETS AS SEVERAL.
3
Features for the Feature List
width height toolbar location directories status scrollbars resizable menubar
4
Methods close myWin.close(); setTimeout
myWin.setTimeout("alert('hello')", 5000); setTimeout executes the given code after the delay in milliseconds. Above example uses 5 seconds. setTimeout is often used recursively, to call the same function that it is in.
5
Methods - Timeouts setTimeout Clearing the timeout:
myTO = myWin.setTimeout("alert('hello')", 5000); Clearing the timeout: myWin.clearTimeout(myTO)
6
Dialog Boxes alert("Hello");
myAnswer = confirm("Click Ok or Cancel, Dude"); returns 'true' or 'false' boolean values. myAnswer2 = prompt("What is your occupation?", "Student"); Returns "Student" or the value you type.
7
Using Frames Each Window is an object This holds true for frames
You can refer to frames by their array index. The array of frames is automatically created. You can refer to a frame by name. You can refer to a window or frame using the self keyword. The parent object is the frameset document. top represents the main frameset.
8
Frames - The HTML You set up your frames in an HTML document that does not show up. It merely establishes the format of the frames.
9
Frames - HTML <frameset cols="20%, 80%">
<frame name="left" src="p1.htm"> <frameset rows="*, 120"> <frame name="main" src="main.htm"> <frame name="footer" src="info.htm"> </frameset> Subsequently you will usually have a target attribute in your anchor (link) tags to indicate which frame you wish to load a document in. We will not cover frames further in this class. A review is warranted if you are not familiar with frames.
10
Changing two Windows To change two frames at once use an event handler. <a href="#" onClick="parent.right.location='loc1.htm'; window.location = 'loc1.htm' "> Notice we are using TWO javascript statements in our event handler. This is acceptable, though calling functions is usually better. The first statement refers to a window called "right". First, though, it must refer to the parent object so it knows where to look for Mr. "right".
11
The Opener If you need to refer to the window that opened a window, you can refer to it as the “opener”: window.opener.document.bgColor = “red";
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.