window对象的open和close方法
2014-11-27 15:25
453 查看
实现一个窗口打开另一个窗口,五秒钟自动关闭的功能;
源网页为:
<html> <head> <script type="text/javascript"> window.open("time.html","","width=400,height=100"); </script> </head> <body></body> </html>打开网页为:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html;charset=gbk"/> <title>计时方法用法</title> <style type="text/css"> #time{width:180px;height:40px;background:#fac;margin:0 auto;font-size:11pt;padding-left:5px;padding-top:10px;color:gray;line-height:20px} </style> <script type="text/javascript"> //setTimeout(update_time,1000); //setInterval(update_time,1000); var id ; function init(){ id = setInterval(update_time,1000); <span style="color:#ff0000;">setTimeout("self.close()",5000);//self.colse()方法</span> } function update_time(){ var date = new Date(); var time = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); document.getElementById('time').innerText = time; } function stop(){ clearInterval(id); } </script> </head> <body onload="init()"> <div id='time'> </div> <input type="button" value="stop" onclick="stop()"/> </body> </html>
此页面五秒后会自动关闭
怎么实现向打开的页面中输入内容?
<html> <head> <script type="text/javascript"> var win=window.open("time.html","","width=400,height=100"); win.document.write("您好!<span style="font-family: Arial, Helvetica, sans-serif;">"/></span> <span style="font-family: Arial, Helvetica, sans-serif;">");</span> </script> </head> <body></body> </html>
相关文章推荐
- 关于JavaScript的window对象的open和close方法
- window.open() | close()方法
- 关于window.open()方法 返回的的打开的新窗口的对象
- (2)window方法:confirm、setTimeout、setInterval、clearInterval、moveBy和moveTo、open和close
- JS:1.7,窗口(window)对象 window.close,window.open
- javascript宿主对象之window.screen、window.close()/open()、window.moveTo、window.resizeTo
- JS窗口问题处理:使弹出窗口保持前端显示的几种方法,及window窗体对象open()和showModalDialog()用法
- 如何让安卓WebView支持js调用window.open()和window.close()的方法。
- JS:1.7窗口(window)对象 window.close,window.open
- window对象open方法详解
- JS窗口问题处理:使弹出窗口保持前端显示的几种方法,及window窗体对象open()和showModalDialog()用法
- JavaScript的window对象的open方法
- window对象的open方法
- window对象open方法详解
- js关闭当前窗口,window.close()方法只能是window.open打开的才能执行关闭
- window的open和showModalDialog方法调用父页面的window对象
- JS窗口问题处理:使弹出窗口保持前端显示的几种方法,及window窗体对象open()和showModalDialog()用法
- JS窗口问题处理:使弹出窗口保持前端显示的几种方法,及window窗体对象open()和showModalDialog()用法
- JavaScript : WINDOW FOR JAVASCRIPT,熟练window对象的open、close、alert、confirm、prompt、setTimeout、clearTimeout、setInterval、clearInterval、
- 在使用JS调用Window.close()方法关闭一个窗口是,如何禁止弹出对话窗口?