javascript怎么自動關(guān)閉窗口

這篇文章主要介紹“javascript怎么自動關(guān)閉窗口”,在日常操作中,相信很多人在javascript怎么自動關(guān)閉窗口問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”javascript怎么自動關(guān)閉窗口”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

創(chuàng)新互聯(lián)是一家從事企業(yè)網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、行業(yè)門戶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計制作的專業(yè)的建站公司,擁有經(jīng)驗豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁設(shè)計人員,具備各種規(guī)模與類型網(wǎng)站建設(shè)的實力,在網(wǎng)站建設(shè)領(lǐng)域樹立了自己獨特的設(shè)計風格。自公司成立以來曾獨立設(shè)計制作的站點成百上千家。

方法:1、使用setTimeout()方法關(guān)閉,語法“setTimeout("clock();",1000);”;2、窗口沒有提示自動關(guān)閉,語法“this.window.opener=null; window.close();”。

本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

第一種:JS定時自動關(guān)閉窗口

<script language="javascript">
<!--
function closewin()
{
self.opener=null;
self.close();
}
function clock()
{
i=i-1
document.title="本窗口將在" + i + "秒后自動關(guān)閉!";
if(i>0)setTimeout("clock();",1000);
else closewin();
}
var i=10
clock();
//-->
</script>

第二種:窗口沒有提示自動關(guān)閉的js代碼

<script language=javascript>  
<!--  
this.window.opener = null;  
window.close();  
//-->  
</script>

擴展資料:

IE6-7 JS關(guān)閉窗口不提示的方法

方法一:

js 代碼

function CloseWin() //這個不會提示是否關(guān)閉瀏覽器    
{    
window.opener=null;    
//window.opener=top;    
window.open("","_self");    
window.close();    
}

方法二:

open.html

js 代碼

function open_complex_self() {    
  var obj_window = window.open('close.html', '_self');    
  obj_window.opener = window;    
  obj_window.focus();    
 }

close.html

js 代碼

window.close();

另附:

//普通帶提示關(guān)閉
function closeie(){
window.close();
}
//關(guān)閉IE6不提示
function closeie6(){
window.opener=null;
window.close();
}
//關(guān)閉IE7不提示
function closeie7(){
window.open('','_top');
window.top.close();
}

到此,關(guān)于“javascript怎么自動關(guān)閉窗口”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

當前文章:javascript怎么自動關(guān)閉窗口
文章地址:http://bm7419.com/article24/gihcce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、網(wǎng)站設(shè)計域名注冊、品牌網(wǎng)站制作、自適應網(wǎng)站、網(wǎng)頁設(shè)計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)