当一个页面要多次访问,比如首页,用
window.open ("page.html", "newwindow", "height=100, width=100, top=0, left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no")
方法,这样每次刷新时都会打开一个新窗口会让人很烦,下面的方法就能解决这个问题:
< script>
function openwin(){
window.open("page.html","","width=200,height=200")
}
function get_cookie(Name) {
var search = Name + "=" var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie("popped")=="){
openwin()
document.cookie="popped=yes"
}
}
< /script>
访问的时候用< body οnlοad="loadpopup()">替换原有的<body>