經常會碰到這個問題,因此我整理了以下兩鐘較簡單的方法:
如何讓彈窗只彈一次:
1.使用asp控制一個會話只彈一次:
<%
if session("ad")<>1 then
%>
<script language=javascript>
function pop_ad(){
window.open('http://www.survivalescaperooms.com','窗口ID','scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes,status=yes,width=300,height=300');
}
setTimeout(pop_ad(),3000);
</script>
<%
session("ad")=1
end if
%>
2.使用js用cookies方式控制只彈出一次窗口
<script language="javascript">
<!--
function openpopup(){
window.open('http://www.survivalescaperooms.com','VeVb',width=300,height=300,left=0,top=0)
}
function GetCookie (name) {
var search = name + "=";
var returnvalue = null;
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents.cookie.indexOf(";",offset);
if (end == -1)
end = documents.cookie.length;
returnvalue=unescape(documents.cookie.substring(offset, end))
}
}
return returnvalue;
}
function pop_ad(){
if (GetCookie('popped')==null||GetCookie('popped')==''){
documents.cookie='popped=yes';
openpopup();
}
}
pop_ad();
//-->
</script>
新聞熱點
疑難解答