您好,欢迎访问一九零五行业门户网

实现在新打开的页面点击关闭窗口的方法

1.在开发过程中我们前端的用户体验中有时候会要求点击一个按钮,关闭当前浏览器窗口。用html dom就可做到。
2.注意:本次写法要求在新窗口中关闭。 target=_blank
3. 由a.html 中打开b.html 在b页面中点击按钮关闭b页面
4. a页面代码
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> </head> <body> <div> <a href='button_colse.html' target="_blank">测试点击按钮关闭当前页面</a> </div> </body> </html>
5. b页面代码
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <style type="text/css"></style> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> </head> <body> <div> 点击我关闭本页面 </div> <button onclick="javascript:window.opener=null;window.open('','_self');window.close();" type="button" role="button" aria-disabled="false"> <span class="ui-button-text"> <span>关闭</span> </span> </button> </body> </html>
以上就是实现在新打开的页面点击关闭窗口的方法的详细内容。
其它类似信息

推荐信息