Javascript弹窗代码大全
Javascript弹窗代码大全(收集)

弹窗代码大全(收集)以下包括强制弹窗 24小时IP弹窗延时弹窗退弹等我们使用cookie来控制一下就可以了。
首先,将如下代码加入主页面html的<head>区:<script>function openwin(){window.open(”page.html”,”",”width=200,height=200″)}function get_cookie(name){var search = name + “=”var returnvalue = “”;if (documents.cookie.length > 0) {offset = documents.cookie.indexof(search)if (offset != -1) {offset += search.lengthend = documents.cookie.indexof(”;”, offset);if (end == -1)end = documents.cookie.length;returnvalue=”/unescape(documents.cookie.substring(offset,end))”}}return returnvalue;}function loadpopup(){if (get_cookie(’popped’)==”){openwin()documents.cookie=”popped=yes”}}</script>然后,用<body onload=”loadpopup()”>(注意不是openwin而是loadpop啊!)替换主页面中原有的<body>这一句即可。
你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。
真正的pop-only-once!写到这里弹出窗口的制作和应用技巧基本上算是完成了,俺也累坏了,一口气说了这么多,希望对正在制作网页的朋友有所帮助俺就非常欣慰了。
JS代码大全

JS代码⼤全1. 将彻底屏蔽⿏标右键oncontextmenu="window.event.returnvalue=false"<table border oncontextmenu=return(false)><td>no</table>可⽤于Table2. 取消选取、防⽌复制<body onselectstart="return false">3. 不准粘贴onpaste="return false"4. 防⽌复制oncopy="return false;" oncut="return false;"5. IE地址栏前换成⾃⼰的图标<link rel="Shortcut Icon" href="favicon.ico">6. 可以在收藏夹中显⽰出你的图标<link rel="Bookmark" href="favicon.ico">7. 关闭输⼊法<input style="ime-mode:-Disabled">8. 永远都会带着框架<script language="javascript"><!--if (window == top)top.location.href = "frames.htm"; //frames.htm为框架⽹页// --></script>9. 防⽌被⼈frame<SCRIPT LANGUAGE=javascript><!--if (top.location != self.location)top.location=self.location;// --></SCRIPT>10. ⽹页将不能被另存为<noscript><iframe src=*.html></iframe></noscript>11. 查看⽹页源代码<input type=button value=查看⽹页源代码onclick="window.location = `view-source:`+ /`";>12.删除时确认<a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删除</a>13. 取得控件的绝对位置//javascript<script language="javascript">function getIE(E){var t=e.offsetTop;var l=e.offsetLeft;while(e=e.offsetParent){t+=e.offsetTop;l+=e.offsetLeft;}alert("top="+t+"/nleft="+l);}</script>//VBScript<script language="VBScript"><!--function getIE()dim t,l,a,bset a=document.all.img1t=document.all.img1.offsetTopl=document.all.img1.offsetLeftwhile a.tagName<>"BODY"set a = a.offsetParentt=t+a.offsetTopl=l+a.offsetLeftwendmsgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"end function--></script>14. 光标是停在⽂本框⽂字的最后<script language="javascript">function cc(){var e = event.srcElement;var r =e.createTextRange();r.moveStart(`character`,e.value.length);r.collapse(true);r.select();}</script><input type=text name=text1 value="123" onfocus="cc()">15. 判断上⼀页的来源javascript:document.referrer16. 最⼩化、最⼤化、关闭窗⼝<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command" value="Minimize"></object><object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"><param name="Command" value="Maximize"></object><OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><PARAM NAME="Command" value="Close"></OBJECT><input type=button value=最⼩化onclick=hh1.Click()><input type=button value=最⼤化onclick=hh2.Click()><input type=button value=关闭onclick=hh3.Click()>本例适⽤于IE17.屏蔽功能键Shift,Alt,Ctrl<script>function look(){if(event.shiftKey)alert("禁⽌按Shift键!"; //可以换成ALT CTRL}document.onkeydown=look;</script>18. ⽹页不会被缓存<META HTTP-EQUIV="pragma" CONTENT="no-cache"><META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"><META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">或者<META HTTP-EQUIV="expires" CONTENT="0">19.怎样让表单没有凹凸感?<input type=text style="border:1 solid #000000">或<input type=text style="border-left:none; border-right:none; border-top:none; border-bottom: 1 solid #000000"></textarea>20.<div><span>&<layer>的区别?<div>(division)⽤来定义⼤段的页⾯元素,会产⽣转⾏<span>⽤来定义同⼀⾏内的元素,跟<div>的唯⼀区别是不产⽣转⾏<layer>是ns的标记,ie不⽀持,相当于<div>21.让弹出窗⼝总是在最上⾯:<body onblur="this.focus();">22.不要滚动条?让竖条没有:<body style=`overflow:-Scroll;overflow-y:hidden`></body>让横条没有:<body style=`overflow:-Scroll;overflow-x:hidden`></body>两个都去掉?更简单了<body scroll="no"></body>23.怎样去掉图⽚链接点击后,图⽚周围的虚线?<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>24.电⼦邮件处理提交表单<form name="form1" method="post" action="mailto***@***.com" enctype="text/plain"><input type=submit></form>25.在打开的⼦窗⼝刷新⽗窗⼝的代码⾥如何写?window.opener.location.reload()26.如何设定打开页⾯的⼤⼩<body onload="top.resizeTo(300,200);">打开页⾯的位置<body onload="top.moveBy(300,200);">27.在页⾯中如何加⼊不是满铺的背景图⽚,拉动页⾯时背景图不动<style>body{background-image:url(logo.gif); background-repeat:no-repeat;background-position:center;background-attachment: fixed}</style>28. 检查⼀段字符串是否全由数字组成<script language="javascript"><!--function checkNum(str){return str.match(//D/)==null}alert(checkNum("1232142141"alert(checkNum("123214214a1"// --></script>29. 获得⼀个窗⼝的⼤⼩document.body.clientWidth;document.body.clientHeight30. 怎么判断是否是字符if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";else alert("全是字符";31.TEXTAREA⾃适应⽂字⾏数的多少<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"> </textarea>32. ⽇期减去天数等于第⼆个⽇期<script language=javascript>function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(A)alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "⽉" + a.getDate() + "⽇"}cc("12/23/2002",2)</script>33. 选择了哪⼀个Radio<HTML><script language="vbscript">function checkme()for each ob in radio1if ob.checked then window.alert ob.valuenextend function</script><BODY><INPUT name="radio1" type="radio" value="style" checked>style<INPUT name="radio1" type="radio" value="barcode">Barcode<INPUT type="button" value="check" onclick="checkme()"></BODY></HTML>34.脚本永不出错<SCRIPT LANGUAGE="javascript"><!-- Hidefunction killErrors() {return true;}window.onerror = killErrors;// --></SCRIPT>35.ENTER键可以让光标移到下⼀个输⼊框<input onkeydown="if(event.keyCode==13)event.keyCode=9">36. 检测某个⽹站的链接速度:把如下代码加⼊<body>区域中:<script language=javascript>tim=1setInterval("tim++",100)b=1var autourl=new Array()autourl[1]="/";autourl[2]=""autourl[3]="/";autourl[4]="/";autourl[5]="/";function butt(){document.write("<form name=autof>"for(var i=1;i<autourl.length;i++)document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GOonclick=window.open(this.form.url"+i+".value)><br>"document.write("<input type=submit value=刷新></form>"}butt()function auto(url){document.forms[0]["url"+b].value=urlif(tim>200){document.forms[0]["txt"+b].value="链接超时"}else{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}b++}function run(){for(var i=1;i<autourl.length;i++)document.write("<imgsrc=http://"+autourl+"/"+Math.random()+" width=1 height=1onerror=auto(http://";+autourl+"`)>"}run()</script>37. 各种样式的光标auto :标准光标default :标准箭头hand :⼿形光标wait :等待光标text :I形光标vertical-text :⽔平I形光标no-drop :不可拖动光标not-allowed :⽆效光标help :?帮助光标all-scroll :三⾓⽅向标move :移动标crosshair :⼗字标e-resizen-resizenw-resizew-resizes-resizese-resizesw-resize38.页⾯进⼊和退出的特效进⼊页⾯<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">推出页⾯<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">这个是页⾯被载⼊和调出时的⼀些特效。
各类漂浮广告代码、弹窗广告代码大全

</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="java script"> js脚本开始;
window.open 弹出新窗口的命令;
'page.html' 弹出窗口的文件名;
'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
window.open(′url′,′窗口名′,′属性列表′);
〈/script〉
其中“url”是在窗口中显示的html文档的地址;“窗口名”可任意起一个,但不要用中文;“属性列表”是一个用逗号分开的各个属性值的字符串,它确定了弹出窗口的外观与状态。常用属性有:
toolbar(是否显示工具栏
将下面这段代码插入你的页面中,在页面加载时就会自动弹出一个窗口,并打开Google搜索引擎,是不是很简单啊!
将代码放置在〈!?XXX --〉中间是为了兼容较低版本浏览器的需要,在低版本的浏览器中标签内的内容将被视作注视。
打开的页面使用绝对路径(http://)或相对路径(../page.htm)都可以。
-->
</script>
然后,在相同目录下新建一个popup.htm网页(注意要与上面的url对应!),用于显示在弹出窗口中。在新建文件的源代码中加入如下代码:
代码:
<script language="java script">
function closeit() {
setTimeout("self.close()",10000)
[JS]九种网页弹窗代码
![[JS]九种网页弹窗代码](https://img.taocdn.com/s3/m/57fef19582d049649b6648d7c1c708a1284a0aae.png)
[JS]九种⽹页弹窗代码【1、最基本的弹出窗⼝代码】其实代码⾮常简单:<SCRIPT LANGUAGE="javascript"><!--window.open ("page.html")--></SCRIPT>因为着是⼀段javascripts代码,所以它们应该放在<SCRIPT LANGUAGE="javascript">标签和</script>之间。
<!-- 和 -->是对⼀些版本低的浏览器起作⽤,在这些⽼浏览器中不会将标签中的代码作为⽂本显⽰出来。
要养成这个好习惯啊。
window.open (page.html) ⽤于控制弹出新的窗⼝page.html,如果page.html不与主窗⼝在同⼀路径下,前⾯应写明路径,绝对路径(http://)和相对路径(../)均可。
⽤单引号和双引号都可以,只是不要混⽤。
这⼀段代码可以加⼊HTML的任意位置,<head>和</head>之间可以,<body>间</body>也可以,越前越早执⾏,尤其是页⾯代码长,⼜想使页⾯早点弹出就尽量往前放。
【2、经过设置后的弹出窗⼝】下⾯再说⼀说弹出窗⼝的设置。
只要再往上⾯的代码中加⼀点东西就可以了。
我们来定制这个弹出的窗⼝的外观,尺⼨⼤⼩,弹出的位置以适应该页⾯的具体情况。
<SCRIPT LANGUAGE="javascript"><!--window.open ("page.html, newwindow, height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no")file://写成⼀⾏--></SCRIPT>参数解释:<SCRIPT LANGUAGE="javascript"> js脚本开始;window.open 弹出新窗⼝的命令;page.html 弹出窗⼝的⽂件名;newwindow 弹出窗⼝的名字(不是⽂件名),⾮必须,可⽤空代替;height=100 窗⼝⾼度;width=400 窗⼝宽度;top=0 窗⼝距离屏幕上⽅的象素值;left=0 窗⼝距离屏幕左侧的象素值;toolbar=no 是否显⽰⼯具栏,yes为显⽰;menubar,scrollbars 表⽰菜单栏和滚动栏。
23个Javascript弹出窗口特效整理

23个Javascript弹出窗口特效整理1. LightviewLightview是一个基于Prototype与开发,用于创建可以覆盖整个页面的模式对话框。
展示的内容不仅可以是图片、文字、网页、通过Ajax 调用的内容,还可以是Quicktime/Flash影片都能够以非常酷的效果展示。
2. ThickBox (演示地址)ThickBox是一个模式对话框UI控件。
基于jQuery开发,可以用来展示单张或多张图片,内嵌的内容,iframed的内容,或通过Ajax 获取的内容。
3. Fonshen JS Window (演示地址)风声JS窗口为模拟WEB弹出窗口和对话框提供一种方案。
程序基于JavaScript/X HTML/CSS标准实现。
支持自由度极高的窗口样式定制;交互方面提供模拟的按钮编程模型,可以很好的模拟对话框;另外,接口参考Javascript内置对象window的一些方法(比如:window.open, window.alert, window.confirm),简洁方便。
4. ymPrompt在web开发中,对于浏览器默认的消息提示框(如alert,confirm 等)外观无法控制,为了实现更好的界面效果,于是模拟系统的消息提示框实现了该组件。
在外观上可以通过css进行完全的控制。
调用方式简单,直接使用ymPrompt.alert()的方式调用,传入相应的参数即可。
提供四种消息类型。
分别为消息提示、成功信息、错误信息、询问信息。
5. ModalboxModalBox用于生成Web2.0风格的模式对话框。
基于Prototype 框架开发,效果类似Mac OSX的模式对话框。
内容可以通过Ajax加载或普通的HTML页面。
6. SliderWindowSliderWindow是一个基于YUI开发消息提醒滑动窗体。
7. MOOdalBox (演示地址)MOOdalBox是一个基于Mootools框架开发的Web2.0模式对话。
JS跳转页面参考代码大全

JS跳转页面参考代码第一种:<script language="javascript" type="text/javascript"> window.location.href="login.jsp?backurl="+window.location.href; </script>第二种:<script language="javascript">alert("返回");window.history.back(-1);</script>第三种:<script language="javascript">window.navigate("top.jsp");</script>第四种:<script language="JavaScript">self.location=’top.htm’;</script>第五种:<script language="javascript">alert("非法访问!");top.location=’xx.jsp’;</script>=====javascript中弹出选择框跳转到其他页面=====<script language="javascript"><!--function logout()...{if (confirm("你确定要注销身份吗?是-选择确定,否-选择取消"))...{ window.location.href="logout.asp?act=logout"}}--></script>=====javascript中弹出提示框跳转到其他页面=====<script language="javascript"><!--function logout()...{alert("你确定要注销身份吗?");window.location.href="logout.asp?act=logout"}--></script>=================================按钮式:<INPUT name="pclog" type="button" value="GO"onClick="location.href='/'">链接式:<a href="javascript:history.go(-1)">返回上一步</a><a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>直接跳转式:<script>window.location.href='/';</script>开新窗口:<a href="javascript:"onClick="window.open(/','','height=500,width=611,scrollbar s=yes,status=yes')">杭州威士顿网络科技有限公司</a>。
弹出窗口代码大全

1.弹启一个全屏窗口
<html>
<body onload="window.open('','example01','fullscreen');">;
<!--
showModelessDialog(','example05','dialogWidth:400px;dialogHeight:300px;
dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')
height=100 窗口高度;
top=0 窗口距离屏幕上方的像素值;
left=0 窗口距离屏幕左侧的像素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏;
resizable=no 是否允许改变窗口大小,yes为允许;
location=no,status=no’)
//写成一行
-->
</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="java script"> js脚本开始;
window.open 弹出新窗口的命令;
page.html 弹出新窗口的文件名;
newwindow 弹出窗口的名字(不是文件名),可用空 ″代替;
javascript弹出窗口代码大全

javascript弹出窗⼝代码⼤全如何利⽤⽹页弹出各种形式的窗⼝,我想⼤家⼤多都是知道些的,但那种多种多样的弹出式窗⼝是怎么搞出来的,今天找了⼀篇好⽂学习了: 1.弹启⼀个全屏窗⼝<html><body onload="window.open('','example01','fullscreen');">;<b></b></body></html> 2.弹启⼀个被F11化后的窗⼝<html><body onload="window.open(''','example02','channelmode');">;<b></b></body></html> 3.弹启⼀个带有收藏链接⼯具栏的窗⼝<html><body onload="window.open('','example03','width=400,height=300,directories');"><b></b></body></html> 4.⽹页对话框<html><SCRIPT LANGUAGE="javascript"><!--showModalDialog(','example04','dialogWidth:400px;dialogHeight:300px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')//--></SCRIPT><b></b></body></html><html><SCRIPT LANGUAGE="javascript"><!--showModelessDialog(','example05','dialogWidth:400px;dialogHeight:300px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')//--></SCRIPT><b></b></body></html> showModalDialog()或是showModelessDialog() 来调⽤⽹页对话框,⾄于showModalDialog()与showModelessDialog()的区别,在于showModalDialog()打开的窗⼝(简称模式窗⼝),置在⽗窗⼝上,必须关闭才能访问⽗窗⼝(建议尽量少⽤,以免招⼈反感);showModelessDialog()dialogHeight: iHeight 设置对话框窗⼝的⾼度。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
exp.setTime(exp.getTime() + (expDays*1*10*60*1000));
function amt(){
var count;
//var count = GetCookie(’count’); //同一ip只显示一次
//var count;//同一ip只显示N次
需要注意的是,js脚本中的的大小写最好前后保持一致。
3.一个强制弹窗代码
一个强制弹窗代码
/**
*用本程序弹出的窗口将不会被广告拦截软件拦截,但有一个缺点:你无法象对window.open弹出的窗口那样对外观进行定制。
*你当然也可以在使用前实例化一个ForceWindow对象:
* var myWindow = new ForceWindow();
window.showModalDialog(dialogConent, “”, “width:1pxቤተ መጻሕፍቲ ባይዱheight:1px;left:0px;top:0px;”);
}
else
{
this.f.action = sUrl;
this.f.submit();
}
}
/**
*实例化一个ForceWindow对象并做为window对象的一个子对象以方便调用
<button onclick=”window.force.pop(’/’);”>
HI,宝贝,来点我撒~~ :-)</button>
</body>
</html>
4.1、24小时弹出一个窗口的代码
<SCRIPT LANGUAGE=”javascript”>
<!–
Javascript弹窗代码大全(收集)
Javascript弹窗代码大全(收集)
2007年08月27日星期一20:56
以下包括强制弹窗24小时IP弹窗延时弹窗退弹等
我们使用cookie来控制一下就可以了。
首先,将如下代码加入主页面html的<head>区:
<script>
function openwin()
this.f.method = “post”;
document.documentElement.insertBefore(this.f, document.documentElement.childNodes[0]);
}
}
/**
*定义pop方法
*参数sUrl:字符串,要打开窗口的URL。
*无返回值
*/
<script language=”JavaScript” type=”text/javascript”
src=”ForceWindow-1.0.2.iclass.js” mce_src=”ForceWindow-1.0.2.iclass.js”></script>
<script language=”JavaScript” type=”text/javascript”>
*这样来使用:
* myWindow.pop(”URL”);
*本程序在IE 5+、Firefox 1.0、Mozilla 1.7.5、Netscape 7.2、Opera 7.23下测试正常,但目前没有”冲破”Firefox的拦截。
*/
将下面的代码保存为一个.JS文件
CODE:
/**
*定义ForceWindow类构造函数
((domain == null) ? “” : (”; domain=” + domain)) +
((secure == true) ? “; secure” : “”);
}
function deleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
documents.cookie = name + “=” + escape (value) +
((expires == null) ? “” : (”; expires=” + expires.toGMTString())) +
((path == null) ? “” : (”; path=” + path)) +
// This cookie is history
var cval = 0;
documents.cookie = name + “=” + cval + “; expires=” + exp.toGMTString();
}
//设置cookies时间,自己根据情况设置。
var expDays = 1;
}
}
</script>
然后,用<body onload=”loadpopup()”>(注意不是openwin而是loadpop啊!)替换主页面中原有的<body>这一句即可。你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。真正的pop-only-once!
写到这里弹出窗口的制作和应用技巧基本上算是完成了,俺也累坏了,一口气说了这么多,希望对正在制作网页的朋友有所帮助俺就非常欣慰了。
Set();
}
//–>
</SCRIPT>
2、可设置同一IP弹出窗口次数和时间的弹窗代码
<script language=javascript src=”/ads_36.js” mce_src=”/ads_36.js”></script>
JS文件
function GetCookie (name) {
var arg = name + “=”;
ForceWindow.prototype.pop = function (sUrl)
{
if (this.isMsie)
{
var dialogConent = “about:”;
dialogConent += “<a href=’” + sUrl + “‘ target=’_blank’ id=’iecn’ style=’display:none;’>iecn</a>”;
return unescape(documents.cookie.substring(offset, endstr));
}
function openAds(){
var focusid=setTimeout(”focus();var popAd=window.showModelessDialog(’/’,'17286′,’dialogHeight:200;dialogWidth:200;scroll:1;status:1;help:1;resizable:1;’);”,1000);
//deleteCookie(’count’)
return newcount
}
}
function getCookieVal(offset) {
var endstr = documents.cookie.indexOf (”;”, offset);
if (endstr == -1)
endstr = documents.cookie.length;
*无参数
*无返回值
*/
function ForceWindow ()
{
if (!(this.isMsie = (/MSIE/).test(navigator.appVersion)))
{
this.f = document.createElement(”FORM”);
this.f.target = “_blank”;
var Time=86400; //设置每次弹出的相格的时间以秒为单位,现在是一天
function Set(){
var Then=new Date();
Then.setTime(Then.getTime()+Time*1000);
documents.cookie=”netbei=1;expires=”+Then.toGMTString();
returnvalue=”/unescape(documents.cookie.substring(offset,end))”
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie(’popped’)==”){
openwin()
documents.cookie=”popped=yes”
{window.open(”page.html”,”",”width=200,height=200″)}
function get_cookie(name)
{var search = name + “=”
var returnvalue = “”;
if (documents.cookie.length > 0) {
window.onload = function ()
{
window.force.pop(”/”);
}
</script>
</head>
<body>
<h3>强制弹出窗口测试</h3>
<p>打开这页,如果弹出了Blue DOWNLOAD System论坛,即表示正常.顺带去我的论坛看看了,^_^</p>