请问如何使一个弹出窗口只弹出一次

主页上做了一个弹出窗口,如何使其只弹出一次,返回主页时不再弹出了。
---------------------------------------------------------------

1<script>   
2window.open("http://www.yeboss.com.cn","yeboss","width=300,height=400")   
3</script>

---------------------------------------------------------------

cookie
---------------------------------------------------------------

 1<head>
 2<script language="JavaScript">   
 3  
 4<!-- Begin   
 5var expDays = 1; // number of days the cookie should last   
 6  
 7var page = "only-popup-once.html";   
 8var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";   
 9  
10function GetCookie (name) {   
11var arg = name + "=";   
12var alen = arg.length;   
13var clen = document.cookie.length;   
14var i = 0;   
15while (i < clen) {   
16var j = i + alen;   
17if (document.cookie.substring(i, j) == arg)   
18return getCookieVal (j);   
19i = document.cookie.indexOf(" ", i) + 1;   
20if (i == 0) break;   
21}   
22return null;   
23}   
24function SetCookie (name, value) {   
25var argv = SetCookie.arguments;   
26var argc = SetCookie.arguments.length;   
27var expires = (argc > 2) ? argv[2] : null;   
28var path = (argc > 3) ? argv[3] : null;   
29var domain = (argc > 4) ? argv[4] : null;   
30var secure = (argc > 5) ? argv[5] : false;   
31document.cookie = name + "=" + escape (value) +   
32((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +   
33((path == null) ? "" : ("; path=" + path)) +   
34((domain == null) ? "" : ("; domain=" + domain)) +   
35((secure == true) ? "; secure" : "");   
36}   
37function DeleteCookie (name) {   
38var exp = new Date();   
39exp.setTime (exp.getTime() - 1);   
40var cval = GetCookie (name);   
41document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();   
42}   
43var exp = new Date();   
44exp.setTime(exp.getTime() + (expDays*24*60*60*1000));   
45function amt(){   
46var count = GetCookie('count')   
47if(count == null) {   
48SetCookie('count','1')   
49return 1   
50}   
51else {   
52var newcount = parseInt(count) + 1;   
53DeleteCookie('count')   
54SetCookie('count',newcount,exp)   
55return count   
56}   
57}   
58function getCookieVal(offset) {   
59var endstr = document.cookie.indexOf (";", offset);   
60if (endstr == -1)   
61endstr = document.cookie.length;   
62return unescape(document.cookie.substring(offset, endstr));   
63}   
64  
65function checkCount() {   
66var count = GetCookie('count');   
67if (count == null) {   
68count=1;   
69SetCookie('count', count, exp);   
70  
71window.open(page, "", windowprops);   
72  
73}   
74else {   
75count++;   
76SetCookie('count', count, exp);   
77}   
78}   
79// End -->   
80</script>
81<body onload="checkCount()">   
82  
83\---------------------------------------------------------------   
84  
85用cookie!!   
86程序上面已给出了!!</body></head>
Published At
Categories with Web编程
comments powered by Disqus