|
有時(shí)為了某種需要,要求進(jìn)入一個(gè)頁(yè)面時(shí)彈出一個(gè)窗口.但每次進(jìn)入時(shí)都會(huì)彈出,就使人感受到煩.怎樣實(shí)只彈出一次呢?下面的程序?qū)?shí)現(xiàn)瀏覽才第一次訪問(wèn)這頁(yè)時(shí)彈出窗口,以后再進(jìn)入則不會(huì)彈出. 在<head>…..</head>之間加入下列代碼: <script languang="javascript"> function openpopup(){ window.open("hello.htm","","width=300,height=300") //自己修改彈出窗口 } function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { // if cookie exists offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } function loadpopup(){ if (get_cookie("popped")==""){ openpopup() document.cookie="popped=yes" } } </script>
將如下代碼鍵入BODY區(qū): <body onload="loadpopup()"> //pop when enter page
|
溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!