More Java Script Objective Hierarchy of Objects document

More Java. Script

Objective �Hierarchy of Objects �document. bg. Color �document. fg. Color �document. link. Color �document. vlink. Color �window. open() �window. close() �window. location �confirm() �window. move. By()

Hierarchy of Objects �Objects follow a strict hierarchy where the window object is the very top level. �Such as: window. alert() �Because window is the top level object it can be omitted. alert(); �The second level of object is window. document �such as: document. write(), document. bgcolor, etc. .

Cont. . document Window bg. Color, fg. Color, link. Color vlink. Color alert() Prompt() Confirm(). .

document. bg. Color and document. fg. Color �document. bg. Color is for changing the background color of page �document. fg. Color is for changing the font color of page �Example <html><head>< title> background and font color</title></head> <body><p> This can be annoying. . . <script type=“text/javascript language="javascript"> document. bg. Color=“red”; document. fg. Color=“blue”; </script> </p> </body> </html>

document. link. Color and document. vlink. Color �document. link. Color is for changing the color of unvisited hyper links �document. vlink. Color is for changing the color of visited links �Example <html><head><title> link color</title></head> <body><p> This can be annoying. . . <script type=“text/javascript language="javascript"> document. link. Color=“red”; document. vlink. Color=“blue”; </script> </p></body></html>

window. open() and window. close() �window. open() is for opening anew window �window. close() is for closing a window �example <html><head><title> open and close window</title></head> <body><p> <script type=“text/javascript language="javascript"> window. open(“www. google. com); window. close(); </script> </p></body></html>

window. location �window. location is for changing the location of a window �example html><head></head> <body> <p> Look at the location on top! <script language="javascript"> newpage=prompt("Enter a URL“, "http: //www. yahoo. com"); window. location=newpage; </script> </center> </body> </html>

Confirm() �Confirm() is a method that produce dialog boxes when called �It is used to get user confirmation from a dialog box containing an OK button that returns true to the script and a cancel button that returns false to the script

Cont. . ask= confirm(“do you want to open a new window? ”); If (ask){ window. open(); } Else{ Alert(“you chose to not open a new window”); }

window. move. By() �window. move. By() is for moving a window either horizontally, vertically, or both, by the specified amount in pixels <html> <head> </head> <body> <p> Did the page just move? <script language="javascript"> answer = confirm("Are you ready? "); if (answer) { window. move. By(100, 100); } </script> </p> </body> </html>
- Slides: 11