<a href="javascript:window.opener=null;window.open('','_self');window.close();">關(guān)閉</a>2.自定義提示關(guān)閉<script language="javascript">
function custom_close(){
if (confirm("您確定要關(guān)閉本頁(yè)嗎?")){
window.opener=null;
window.open('','_self');
window.close();
}
else{}
}
</script>
// 這個(gè)腳本是 ie6和ie7 通用的腳本
<input id="btnClose" type="button" value="關(guān)閉本頁(yè)" onClick="custom_close()" />3.關(guān)閉當(dāng)前頁(yè)面:<a href="javascript:window.opener=null;window.close();">關(guān)閉</a>,如果是按鈕則:Response.Write("<script language="javascript">window.opener=null;window.close();</script>");這樣點(diǎn)關(guān)閉的時(shí)候就不會(huì)彈出如當(dāng)前窗口正試圖關(guān)閉的對(duì)話框了.那么怎么樣當(dāng)用戶點(diǎn)瀏覽器的最大化最小化關(guān)閉按鈕中的關(guān)閉按鈕時(shí)也彈出關(guān)閉的確認(rèn)對(duì)話框呢?這樣:
<body onbeforeunload="return '真的要關(guān)閉此窗口嗎?'">這樣的話在點(diǎn)關(guān)閉時(shí)候就會(huì)執(zhí)行onbeforeunload函數(shù),彈出真的要關(guān)閉此窗口嗎的對(duì)話框,點(diǎn)取消返回假,不關(guān)閉,點(diǎn)確定返回真關(guān)閉窗口
那么怎么樣才能夠點(diǎn)擊某個(gè)按鈕的時(shí)候彈出確定取消對(duì)話框呢??如果點(diǎn)取消就不執(zhí)行下面的代碼,點(diǎn)確定就繼續(xù)執(zhí)行下面的代碼?
在按鈕的單擊里寫:
Response.Write("<script language=javascript">" + "if(confirm("確定嗎?"))"+"{window.location.href='default.aspx';}"+"else{history.back();}"+"</script>");意思是:首先用confirm函數(shù)彈出個(gè)有確定取消的對(duì)話框,如果你點(diǎn)了確定就返回真,就執(zhí)行window.location.href='default.aspx'代碼,如果點(diǎn)了取消就返回假,就執(zhí)行history.back();返回到原來(lái)的頁(yè)面
我是有底線的
掃描二維碼手機(jī)查看該文章
文章引用:http://www.qingbaosc.com/news/webzhishi/1445.html




