Window object
Alert () Displays an alert box with a message and a confirmation button prompt () displays a dialog box that prompts the user for input confirm () displays a dialog box with a message and a Penguin button and a Cancel button open () Open a new browser window or find a named window close () Closes the browser window print () prints the contents of the current window focus () give the keyboard focus to a window blur () Remove the keyboard focus from the top-level window Moveby () The current coordinates of the window can be moved to move the specified pixel moveto () moves the upper-left corner of the window to a specified coordinate Resizeby () resizes the window by the specified pixel Resizeto () Adjusts the size of the window to the specified width and height Scrollby () Scrolls the content by the specified pixel value Scrollto () scrolls the content to the specified coordinates setinterval () executes the Code settimeout () after the specified delay time to execute code clearinterval () Cancel SetInterval Settings cleartimeout () Cancel settimeout settings
Timer:
SetInterval (Code, interaction time);
var attime;
function Clock () {
var time=new Date ();
Attime= time.gethours () + ":" +time.getminutes () + ":" +time.getseconds ();
document.getElementById ("Clock"). Value = Attime;
}
SetInterval (clock,1000);
Timer:
SetTimeout (code, delay time);
var num=0;function numcount () {document.getElementById (' txt '). value=num; num=num+1; SetTimeout ("Numcount ()", 1000);}
History Object
The history object records the pages (URLs) that the user has browsed, and enables the browser to move forward and backward with similar navigation capabilities. Window.history. [Properties | Method]length Returns the number of URLs in the browser history list back () loads the first URL in the historical list forward () loads the next Urlgo () in the Legacy list Load a specific page in the history list
Back () method to load the previous URL in the History list. For example, return to the previous browse page, the code is as follows: Window.history.back (); Note: The reverse button is the same as clicking the browser. Back () equivalent to go (-1), the code is as follows: Window.history.go (-1);
Return to the next Browse page forward () method to load the next URL in the history list. If you want to go back to the page you browsed before going backwards, you can use the forward () method, with the following code: Window.history.forward (); forward () equivalent to go (1), window.history.go (1);
The location object property property describes the hash setting or returns the URL (anchor) starting from (#) host setting or returning the host name and the port number of the current URL hostname Sets or returns the hostname of the current URL href setting or returns the full Urlpathname setting or returns the path of the current URL section port setting or returning the port number of the current URL protocol Sets or returns the Protocol search setting for the current URL or returns the from question mark (? Start URL (query section) Locationobject Method Property Description Assign () load New document reload () Reload current document replace () Replace the current document with a new document
The Navigator Object Property describes the string representation of the appCodeName Rover code name appname returns the name of the browser appversion Returns the platform and version information for the browser platform returns the value of the user-agent header of the server that was sent by the client useragent returns the operating system platform running the browser
Display browser and browser related information
<script type= "Text/javascript" > function Validb () { var u_agent =navigator.useragent; ; var b_name= "not want to use the mainstream browser!"; if (U_agent.indexof ("Firefox") >-1) { b_name= "Firefox"; } else if (U_agent.indexof ("Chrome") >-1) { b_name= "chrome"; } else if (U_agent.indexof ("MSIE") >-1&&u_agent.indexof ("Trident") >-1) { b_name= "IE (8-10)"; } document.write ("Browser:" +b_name+ "<br>"); document.write ("U_agent:" +u_agent+ "<br>"); } </script>
Window.screen Object
document.write ("screen width:" +screen.width+ "px<br/>"); View screen width document.write ("screen height:" +screen.height+ "px<br/>"); viewing screen height
document.write ("Usable width:" + screen.availwidth); Viewing the available width of the screen
document.write ("Available height:" + screen.availheight); Viewing the screen's available height
JavaScript Browser Object