<html> <head> <meta charset="utf-8"> <title>window对象属性</title> </head> <body onunload="closeChild()"> <div id="scrollDiv"> </div> <script language="javascript"> //01 closed属性 //var child=window.open("http://www.baidu.com","_blank"); //** var child=window.open("test.html","_blank"); function closeChild(){ if(child.closed==false){ child.close(); } } //*/ //02 opener属性 执行父级窗口的引用 //下面的例子可向 opener 窗口写文本(父窗口) child.document.write("this is child window!!"); child.opener.document.write("this is parent window!"); //03 defaultstatus 该文本会在页面加载时被显示。 //status 设置和返回窗口状态栏上所显示的文本内容 window.defaultstatus="窗口"; window.status="@@@@@@@@@@@@@@@@"; //04 screenTop screenLeft child.screenTop="0"; child.screenLeft="0"; //重载在当前页面 //window.reload(); //测试小结:实现文本在状态栏上左右移动的效果 var strStatus="夜上海"; var space_num=0; var dir=1; function scroll(){ var str_space=""; space_num+=1*dir; if(space_num>40||space_num<=0){ dir=-1*dir; } for(var i=0;i<space_num;i++){ str_space+=" "; } window.status=str_space+strStatus; } window.setInterval("scroll()",100); //在浏览器窗口做一个移动显示的文字 var scroll=document.getElementById("scrollDiv"); function scrollDiv(){ var str_space=""; space_num+=1*dir; if(space_num>40||space_num<=0){ dir=-1*dir; } for(var i=0;i<space_num;i++){ str_space+=" "; } scroll.innerHTML=str_space+strStatus; } window.setInterval("scrollDiv()",700); </script> </body> </html>
1 <html> 2 <head> 3 <meta charset="utf-8"> 4 <title>window对象属性</title> 5 </head> 6 7 <body onunload="closeChild()"> 8 <div id="scrollDiv"> 9 10 </div> 11 12 <script language="javascript"> 13 //01 closed属性 14 //var child=window.open("http://www.baidu.com","_blank"); 15 //** 16 var child=window.open("test.html","_blank"); 17 function closeChild(){ 18 if(child.closed==false){ 19 child.close(); 20 } 21 } 22 //*/ 23 //02 opener属性 执行父级窗口的引用 24 //下面的例子可向 opener 窗口写文本(父窗口) 25 child.document.write("this is child window!!"); 26 child.opener.document.write("this is parent window!"); 27 28 //03 defaultstatus 该文本会在页面加载时被显示。 29 //status 设置和返回窗口状态栏上所显示的文本内容 30 window.defaultstatus="窗口"; 31 window.status="@@@@@@@@@@@@@@@@"; 32 33 //04 screenTop screenLeft 34 child.screenTop="0"; 35 child.screenLeft="0"; 36 37 //重载在当前页面 38 //window.reload(); 39 40 //测试小结:实现文本在状态栏上左右移动的效果 41 var strStatus="夜上海"; 42 var space_num=0; 43 var dir=1; 44 function scroll(){ 45 var str_space=""; 46 space_num+=1*dir; 47 if(space_num>40||space_num<=0){ 48 dir=-1*dir; 49 } 50 for(var i=0;i<space_num;i++){ 51 str_space+=" "; 52 } 53 window.status=str_space+strStatus; 54 } 55 window.setInterval("scroll()",100); 56 57 //在浏览器窗口做一个移动显示的文字 58 var scroll=document.getElementById("scrollDiv"); 59 function scrollDiv(){ 60 var str_space=""; 61 space_num+=1*dir; 62 if(space_num>40||space_num<=0){ 63 dir=-1*dir; 64 } 65 for(var i=0;i<space_num;i++){ 66 str_space+=" "; 67 } 68 scroll.innerHTML=str_space+strStatus; 69 } 70 window.setInterval("scrollDiv()",700); 71 </script> 72 </body> 73 </html>