【溫故而知新-Javascript】窗口效果 (全屏顯示窗口、定時關閉窗口)


1.全屏顯示窗口

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>全屏顯示窗口</title>
</head>

<body>
<div align="center">
<input type="button" name="FullScreen" value="全屏顯示"
onclick="window.open(document.location,'big','fullscreen=yes')"  />
</div>
</body>
</html>

 

2.定時關閉窗口

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>定時關閉窗口</title>
<script type="application/javascript">
var i=6;
clock();
function clock()
{
    document.title = "本窗口將在"+i+"秒后自動關閉!";
    i --;
    if(i>0) setTimeout("clock()",1000);
    else 
    {     
    // 1.在Firefox地址欄里輸入 about:config
    // 2.在配置列表中找到 dom.allow_scripts_to_close_windows 
    // 3.點右鍵的選切換把上面的false修改為true即可。 
    //注:默認是false,是為了防止腳本亂關窗口
    //FireFox中做如此設置以后,直接使用"window.close()"即可對窗口關閉。
    
    //window.open('','_self','');針對chrome瀏覽器,添加此代碼,不過我這測試沒用,依然警告:Scripts may close only the windows that were opened by it. 
    window.close();
    }
}
</script>
</head>

<body>
</body>
</html>

 

 

來源:《HTML、CSS、Javascript網頁制作從入門到精通》15.3章節

PS:IE下有效


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM