Document.defaultview or global variable window--gets a Window object.
1) Get form information
Innerheight, innerwidth--gets the height and width of the form content area.
Outerheight, outerwidth--Gets the height, width of the form (including border and menu bar, etc.);
Pagexoffset, pageyoffset--gets the number of pixels that the form has scrolled horizontally/vertically from the upper-left corner;
screen--returns a screen object that describes the display;
The height and width of the form section (excluding toolbars and menu bars) can be displayed on the screen.availheight, screen.availwidth--screen;
screen.colordepth--the color depth of the screen;
Screen.height, screen.width--screen height, width;
screenleft/screenx--gets the pixels from the left edge of the form to the left edge of the screen (note browser compatibility).
screentop/screeny--gets the pixels from the top edge of the form to the top edge of the screen (note browser compatibility);
2) interacting with the form
Blur ()--Let the form lose keyboard focus;
Close ()--Closes the form (not all browsers agree that a script closes the form).
Focus ()--Lets the form get keyboard focus.
Print ()--Prompts the user for printing the page;
Scrollby (<x>,<y>)--Lets the document scroll relative to the current position.
ScrollTo (<x>,<y>)--scrolls to the specified position.
Stop ()-Stops loading the document.
3) Prompt the user
Alert (<msg>)-Prompts the user for a dialog box form and waits for it to be closed;
Confirm (<msg>)-Displays a dialog box form with confirmation and cancellation (returns a Boolean value);
Prompt (<msg>,<val>)--Displays a dialog box prompting the user to enter a value (return string);
ShowModalDialog (<url>)--pops up a form that displays the specified URL;
4) Properties and methods of the History object
Back ()--a step backwards in browsing history;
Forward ()--a step forward in the history of browsing;
Go (<index>)--go to a browsing history location relative to the current document. Positive value is forward, negative value is backward;
length--returns the number of items in the browsing history.
Pushstate (<state>,<title>,<url>)--Add an entry to the browser history;
Replacestate (<state>,<title>,<url>)--Replaces the current entry in the browser history;
state--returns the status data associated with the current document in the browser history;
5) using cross-document messaging
PostMessage (<msg>,<origin>)-sends a specified message to another document;
Look for the inline window:
defaultview--returns the window of the active document;
frames--returns an array of Window objects for the IFRAME element embedded in the document;
opener--returns the window that opens the current browsing context.
parent--returns the parent window of the current window;
self--returns the window of the current document;
top--returns to the topmost window;
length--returns the number of IFRAME elements embedded in the document;
[<index>]--returns the window for the embedded document at the specified index location.
[<name>]--returns the window with the specified name embedded in the document;
6) Using Timers
SetTimeout (<function>,<time>)--Creates a timer that waits for a time millisecond to invoke the specified function;
Cleartimeout (<id>)--revokes a timeout timer.
SetInterval (<function>,<time>)--Creates a timer that invokes the specified function every time millisecond;
Clearinterval (<id>)--undo a time interval timer;
<! DOCTYPE html>All the way in. Isaac will build a professional, honest and win-wins through its own professional advantages and effective information exchange platform for the rich and the fund demand side. Intelligent Service platform to help customers achieve stable and secure wealth and value-added. Help many other good small and medium enterprises to finance success. Far in the spirit of "building integrity, sustainable development" concept to provide customers with professional financial services, wealth management Solutions and product recommendations. All the way in here. Through its own professional advantages and effective information exchange platform, to create a professional, honest, winning, intelligent service platform for the rich and the fund demand side, to help customers achieve stable, safe wealth and value-added. Help many other good small and medium enterprises to finance success.
Far in the spirit of "building integrity, sustainable development" concept to provide customers with professional financial services, wealth management and product proposal recommendations. All the way in. Isaac will build a professional through its own professional advantages and effective information exchange platform for the rich and the fund demand side. Good faith, win. Intelligent Service platform to help customers achieve stable and secure wealth and value-added. Help many other good small and medium enterprises to finance success.
</p> <p id= "status" >Ready</p> <button id= "send" >send message</button> <p> <iframe name= "nested" src= "http://localhost:63342/IDEA-workspace/Demotest/otherdomain.html" width= "90%" height= "100px" ></iframe> </p> <p id= "MSG2" ></p> <p id= "BUTTONS5" > <button id= "SetTime" >set time</button> <button id= "Cleartime" >clear time</button> <button id= "s Etinterval ">set interval</button> <button id=" clearinterval ">clear Interval</button> </p > <script>//Get form Information document.getElementById ("Ow"). Innerhtml=window.outerwidth; document.getElementById ("Oh"). Innerhtml=document.defaultview.outerheight; document.getElementById ("IW"). Innerhtml=window.innerwidth; document.getElementById ("IH"). Innerhtml=window.innerheight; document.getElementById ("SW"). Innerhtml=window.screen.width; document.getElementById ("sh"). Innerhtml=window.screen.height; </script> <script>//interact with the form Var Buttons=document.getelementbyid ("Buttons1"). Getelementsbytag Name ("button"); for (Var i=0;i<buttons.length;i++) {buttons[i].onclick=handlebuttonpress; } function Handlebuttonpress (e) {if (e.target.id== "print") {window.print (); }else if (e.target.id== "close") {window.close (); }else{Window.scrollto (0,800); }} </script> <script>//Prompts the user for Var Buttons2=document.getelementbyid ("Buttons2"). Gete Lementsbytagname ("button"); for (Var i=0;i<buttons2.length;i++) {buttons2[i].onclick=handlebuttonpress2; } function HandleButtonPress2 (e) {if (e.target.id== "alert") {Window.alert ("This is a hint box"); }else if (e.target.id== "confirm") {var confirmed=windOw.confirm ("This is a confirmation box, OK to continue?") Alert ("OK?"). "+confirmed); }else if (e.target.id== "prompt") {var response=window.prompt ("Enter a word", "hello"); Alert ("The word is:" +response); }else if (e.target.id== "modal") {window.showModalDialog ("http://www.sina.com.cn"); }} </script> <script>//navigating Var Buttons3=document.getelementbyid ("Buttons3") in browsing history. GE Telementsbytagname ("button"); for (Var i=0;i<buttons3.length;i++) {buttons3[i].onclick=handlebuttonpress3; } function HandleButtonPress3 (e) {if (e.target.id== "back") {Window.history.back (); }else if (e.target.id== "forward") {Window.history.forward (); }else if (e.target.id== "Go") {window.history.go ("http://www.sina.com.cn"); }} </script> <script>//Add an entry to browsing history var sel= "no selection made"; if (window.location.search== "?)
Banana ") {sel= "Selection:banana"; }else if (window.location== "? Apple") {sel= "selection:apple"; } document.getElementById ("MSG"). Innerhtml=sel; var Buttons4=document.getelementbyid ("Buttons4"). getElementsByTagName ("button"); for (Var i=0;i<buttons4.length;i++) {buttons4[i].onclick=function (e) {document.getElementById ( "MSG"). Innerhtml= e.target.innerhtml; Window.history.pushState ("", "" "," otherdomain.html? ") + e.target.id); Replaces the current entry in the browser history window.history.replaceState ("", "", "otherdomain.html?
"+ e.target.id); }} </script> <script>/Cross document issue document.getElementById ("send"). Onclick=function () { Locate the Window object and call the PostMessage method window["nested"].postmessage ("I like Apples", "http://localhost:63342"); document.getElementById ("status"). Innerhtml= "Message Sent"; } </script> <script> var buttons5=document.getelementbyid ("Buttons5"). getElementsByTagName ("Butto n "); for (Var i=0;i<buttons5.length;i++) {buttons5[i].onclick=handlebuttonpress4; } var Timeid; var intervalid; var count=0; function HandleButtonPress4 (e) {if (e.target.id== "SetTime") {Timeid=settimeout (function () { Displaymsg ("Timeout Expired"); },5000); Displaymsg ("Timeout set"); }else if (e.target.id== "Cleartime") {cleartimeout (Timeid); Displaymsg ("TimeOut cleared "); }else if (e.target.id== "SetInterval") {Intervalid=setinterval (function () {displaymsg ("Int Erval Expired. Counter: "+count++); },2000); Displaymsg ("Interval set"); }else if (e.target.id== "Clearinterval") {clearinterval (intervalid); Displaymsg ("Interval cleared"); }} function Displaymsg (msg) {document.getElementById ("MSG2"). Innerhtml=msg; } </script></body>
Otherpage Code:
<! DOCTYPE html>
JavaScript Action Window Object