怎样用JS关闭当前页面

JavaScript023

怎样用JS关闭当前页面,第1张

js 关闭窗口的方法:

1、 不带任何提示关闭窗口的js代码

<a href="javascript:window.opener=nullwindow.open('','_self')window.close()">关闭</a>

2、自定义提示关闭

<script language="javascript">

// 这个脚本是 ie6和ie7 通用的脚本

function custom_close(){

if

(confirm("您确定要关闭本页吗?")){

window.opener=null

window.open('','_self')

window.close()

}

else{}

}

</script>

<input id="btnClose" type="button" value="关闭本页" onClick="custom_close()" />

准备的材料分别是:chrome浏览器、电脑。

1、首先打开chrome浏览器,点击菜单上的“设置”按钮。

/iknow-pic.cdn.bcebos.com/f31fbe096b63f6245621f0e08944ebf81b4ca3d1"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/f31fbe096b63f6245621f0e08944ebf81b4ca3d1?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/f31fbe096b63f6245621f0e08944ebf81b4ca3d1"/>

2、其次,鼠标拉到底部,点击底部的“高级”按钮。

/iknow-pic.cdn.bcebos.com/72f082025aafa40fac9c073ea564034f79f019ff"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/72f082025aafa40fac9c073ea564034f79f019ff?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/72f082025aafa40fac9c073ea564034f79f019ff"/>

3、接着,点击“网站设置”按钮。

/iknow-pic.cdn.bcebos.com/6c224f4a20a4462338b36c819622720e0df3d7dc"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/6c224f4a20a4462338b36c819622720e0df3d7dc?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/6c224f4a20a4462338b36c819622720e0df3d7dc"/>

4、从弹出的面板,再再点击“JavaScript”菜单。

/iknow-pic.cdn.bcebos.com/cefc1e178a82b901b3d40ad07d8da9773812efdd"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/cefc1e178a82b901b3d40ad07d8da9773812efdd?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/cefc1e178a82b901b3d40ad07d8da9773812efdd"/>

5、最后将“允许(推荐)”按钮打开,之后刷新页面即可生效。

/iknow-pic.cdn.bcebos.com/dcc451da81cb39db66b8aeb5de160924aa1830dd"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/dcc451da81cb39db66b8aeb5de160924aa1830dd?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/dcc451da81cb39db66b8aeb5de160924aa1830dd"/>