Window object methods and events
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" ><html> <head> <title>Window object methods and events</title> <script type="Text/javascript"> /*alert (Window.screen); alert (window.history); alert (window.location); */ //window The method of the object, because the Window object is a global object, you can omit the window /*var flag=window.confirm ("OK to close?") ") if (flag) {Window.alert (" off "); }else{alert ("Cancel"); }*/ Events in//window /*window.onload=function () {Alert ("page loading complete!) "); };*/ /*window.onmouseover=function () {alert ("Mouse over form! "); }; */ /*window.onclick=function () {alert ("I am the form, I was ordered by someone!") "); }*/ //Call the getElementById () method of the Document object to get the element object that specifies the ID name on the pageWindow.onload= function(){ varUsername=document.getelementbyid ("username"); Username.onchange= function(){Alert"The value of the text box is changed!"); }; };</script> </head> <body> <input type="button" value="Confirm Close" onclick=" Confirm (' Are you sure you want to close? ') "/><br/> <input type="button" value="Close window" onclick ="Window.close ();" /><br/> <input type="button" value="Popup window 1" onclick=" window.open (' test01.html '); /><br/> <input type="button" value="Popup 2" onclick ="window.open (' test01.html ', ' Window 2 ', ' width=300px,height=300px ');" /><br/>User name:<input type="text" name= "username" id="username" onkeyup="alert (' Input data ')" /> </body></html>
Interview questions
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" ><html> <head> <title>Test05.html</title> <script type="Text/javascript"> varx=1, y=z=0; function add(num){ returnnum=num+1; } y=add (x); function add(num){ returnnum=num+3; } z=add (x);//alert (x+ "," +y+ "," +z "); function calc(num1,num2){alert (NUM1+NUM2); } function calc(num1,num2,num3){alert (NUM1+NUM2+NUM3); } function calc(num1){alert (NUM1); }</script> </head> <body> <input type="button" value="" onclick=" Calc (5,8,2); " /> </body></html>
Javascript-window Object Methods and events