Window ??? ?? ???? ???
open() ???
??: ? ???? ?? ???.
??: ??var winObj = window.open([url][,name][,options]);
??: ????? ?? ?????. ????? ???? ??? ? ?? ????(??? ????).
????:
url: ? ?? ??? ??? ? ?????. url? ? ???? ???? ???? ? ???? ? ????.
name: ? ?? ?????. ? ??? ??? ?? ??? ?????.
options: ?? ?????.???????????????????????????????????????????????????????????????????????????????????????????????????????????~ >
??: ?? ??? ?? ??.是否 ??: ?? ???? ???? ?????.
??:
onload ???: ? ???(??)? ? ???? ???? ??? ?? ???? ??? ?? ??????. JS ??? ????? onload ??? ??? ?????. onload ??? body ????? ??? ? ????.
onclick ???: ?? ? JS ??? ?????. ?? HTML ???? ? ??? ??? ????.
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> function init(){ window.open("","php.cn") } </script> </head> <body onload="init()"> </body> </html>
Delayer ??? - setTimeout()
setTimeout()
??: ?? ??? ?????. ?, ??? ? ?? ?? ?????. ? JS ??? ? ?.
- ??: ??var ??? = window.setTimeout(code,millisec)
- ????:
- ??: ?? ???? JS ??, ????? JS ?????. ??? ???? ??? ???. O ?: Window.Settimeout ("Close ()", 2000) ?: Window.Settimeout (Init, 2000); // ?? ??? ????? ???? ??? ??? ????. ??? ???? ??? ?? ??? ???? ?????.
- clearTimeout()
??: ??window.clearTimeout(timer)
- ????: ???? setTimeout() id ??? ??? ??????.
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> function init(){ //打開一個(gè)新窗口 var win=window.open(); win.document.write("歡迎來到php.cn") ; //新窗口2秒后關(guān)閉 win.setTimeout("window.close()",2000); } </script> </head> <body onload="init()"> </body> </html>
Timer method
setInterval()
??: var ??? = window.setInterval(code, millisec)
????:
??: ???? JS ???? ????? JS ?????. ??? ???? ??? ???. + ? ??? ???? ??? ?? ??? ???? ?????.
????????????????????????? ???: ??? ?. 1? = 1000???
???: ???? id ??? ?????. ? id ???clearInterval()? ?????.
- clearInterval()
??: ??? ID ?? ???
??: ??window.clearInterval(timer)
????: ???? setInterval()? ?? ??? ???? ID???. ??? ??.