Javascript弹窗代码大全收集Word格式.docx
- 文档编号:16997013
- 上传时间:2022-11-27
- 格式:DOCX
- 页数:14
- 大小:23.61KB
Javascript弹窗代码大全收集Word格式.docx
《Javascript弹窗代码大全收集Word格式.docx》由会员分享,可在线阅读,更多相关《Javascript弹窗代码大全收集Word格式.docx(14页珍藏版)》请在冰豆网上搜索。
这一句即可。
你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。
真正的pop-only-once!
写到这里弹出窗口的制作和应用技巧基本上算是完成了,俺也累坏了,一口气说了这么多,希望对正在制作网页的朋友有所帮助俺就非常欣慰了。
需要注意的是,js脚本中的的大小写最好前后保持一致。
3.一个强制弹窗代码
一个强制弹窗代码
/**
*用本程序弹出的窗口将不会被广告拦截软件拦截,但有一个缺点:
你无法象对window.open弹出的窗口那样对外观进行定制。
*你当然也可以在使用前实例化一个ForceWindow对象:
*varmyWindow=newForceWindow();
*这样来使用:
*myWindow.pop(”URL”);
*本程序在IE5+、Firefox1.0、Mozilla1.7.5、Netscape7.2、Opera7.23下测试正常,但目前没有”冲破”Firefox的拦截。
*/
将下面的代码保存为一个.JS文件
CODE:
*定义ForceWindow类构造函数
*无参数
*无返回值
functionForceWindow()
{
if(!
(this.isMsie=(/MSIE/).test(navigator.appVersion)))
this.f=document.createElement(”FORM”);
this.f.target=“_blank”;
this.f.method=“post”;
document.documentElement.insertBefore(this.f,document.documentElement.childNodes[0]);
*定义pop方法
*参数sUrl:
字符串,要打开窗口的URL。
ForceWindow.prototype.pop=function(sUrl)
if(this.isMsie)
vardialogConent=“about:
”;
dialogConent+=“<
ahref=’”+sUrl+“‘target=’_blank’id=’iecn’style=’display:
none;
’>
iecn<
/a>
scriptlanguage=’JavaScript’type=’text/javascript’>
dialogConent+=“document.getElementById(’iecn’).click();
window.close();
window.showModalDialog(dialogConent,“”,“width:
1px;
height:
left:
0px;
top:
”);
else
this.f.action=sUrl;
this.f.submit();
*实例化一个ForceWindow对象并做为window对象的一个子对象以方便调用
*定义后可以这样来使用:
window.force.pop(”URL”);
window.force=newForceWindow();
测试部分.
html>
title>
ForceWindow测试<
/title>
metahttp-equiv=”Content-Type”content=”text/html;
charset=gb2312″>
scriptlanguage=”JavaScript”type=”text/javascript”
src=”ForceWindow-1.0.2.iclass.js”mce_src=”ForceWindow-1.0.2.iclass.js”>
scriptlanguage=”JavaScript”type=”text/javascript”>
window.onload=function()
window.force.pop(”
/head>
h3>
强制弹出窗口测试<
/h3>
p>
打开这页,如果弹出了BlueDOWNLOADSystem论坛,即表示正常.顺带去我的论坛看看了,^_^<
/p>
buttononclick=”window.force.pop(’
HI,宝贝,来点我撒~~:
-)<
/button>
/body>
/html>
4.1、24小时弹出一个窗口的代码
SCRIPTLANGUAGE=”javascript”>
!
–NETBEI.COM
varTime=86400;
//设置每次弹出的相格的时间以秒为单位,现在是一天
functionSet(){
varThen=newDate();
Then.setTime(Then.getTime()+Time*1000);
documents.cookie=”netbei=1;
expires=”+Then.toGMTString();
varcookieString=newString(documents.cookie);
varcookieHeader=”netbei=”;
varbeginPosition=cookieString.indexOf(cookieHeader);
if(beginPosition<
0){
window.open(”//设置弹出窗口的大小
Set();
//–>
/SCRIPT>
2、可设置同一IP弹出窗口次数和时间的弹窗代码
scriptlanguage=javascriptsrc=”/ads_36.js”mce_src=”/ads_36.js”>
JS文件
functionGetCookie(name){
vararg=name+“=”;
varalen=arg.length;
varclen=documents.cookie.length;
vari=0;
while(i<
clen){
varj=i+alen;
if(documents.cookie.substring(i,j)==arg)
returngetCookieVal(j);
i=documents.cookie.indexOf(”“,i)+1;
if(i==0)break;
returnnull;
functionSetCookie(name,value){
varargv=SetCookie.arguments;
varargc=SetCookie.arguments.length;
varexpires=(argc>
2)?
argv[2]:
null;
varpath=(argc>
3)?
argv[3]:
vardomain=(argc>
4)?
argv[4]:
varsecure=(argc>
5)?
argv[5]:
false;
documents.cookie=name+“=”+escape(value)+
((expires==null)?
“”:
(”;
expires=”+expires.toGMTString()))+
((path==null)?
path=”+path))+
((domain==null)?
domain=”+domain))+
((secure==true)?
“;
secure”:
“”);
functiondeleteCookie(name){
varexp=newDate();
exp.setTime(exp.getTime()-1);
//Thiscookieishistory
varcval=0;
documents.cookie=name+“=”+cval+“;
expires=”+exp.toGMTString();
//设置cookies时间,自己根据情况设置。
varexpDays=1;
exp.setTime(exp.getTime()+(expDays*1*10*60*1000));
functionamt(){
varcount;
//varcount=GetCookie(’count’);
//同一ip只显示一次
//varcount;
//同一ip只显示N次
//alert(count);
//count=null;
if(count==null){
SetCookie(’count’,'
1′)
return1
else{
varnewcount=parseInt(count)+1;
if(newcount<
2)count=1;
SetCookie(’count’,newcount,exp);
//deleteCookie(’count’)
returnnewcount
functiongetCookieVal(offset){
varendstr=documents.cookie.indexOf(”;
if(endstr==-1)
endstr=documents.cookie.length;
returnunescape(documents.cookie.substring(offset,endstr));
functionopenAds(){
varfocusid=setTimeout(”focus();
varpopAd=window.showModelessDialog(’
self.focus();
if(amt()==1)
openAds()
3、3721和MYIE屏蔽不掉的弹窗代码
Code:
focusid=setTimeout(”window.showModelessDialog(’pen.htm’,”,’scroll:
0;
status:
1;
help:
resizable:
0′)”,0000)
上面代码另存为.JS
调用代码
scriptsrc=”/*.js”mce_src=”/*.js”>
4、用Cookie实现仅弹出一次窗口
脚本说明:
第一步:
把如下代码加入<
区域中
SCRIPTlanguage=”javascript”>
–
functionopenpopup(){
window.open(”welcome.htm”,”"
”width=300,height=300″)
functionget_cookie(Name){
varsearch=Name+“=”
offset=documents.cookie.indexOf(search)
=-1){//ifcookieexists
//setindexofbeginningofvalue
end=documents.cookie.indexOf(”;
//setindexofendofcookievalue
returnvalue=”/unescape(documents.cookie.substring(offset,”end))
if(get_cookie(’popped’)==’){
openpopup()
第二步:
把<
中内容改为:
bodybgcolor=”#fef4d9″onunload=”loadpopup()
5、展开式的弹出窗口
网页上的弹出窗口见得多了,但是没有什么很新颖的效果来显示其过程。
你学完这个实例后你就会感觉并不是那么回事,可让你的弹出窗口也活动起来。
制作方法:
将下面的代码复制到<
~<
里:
scriptlanguage=javascript>
functionexpandingWindow(website){
varheightspeed=2;
//verticalscrollingspeed(higher=slower)
varwidthspeed=7;
//horizontalscrollingspeed(higher=slower)
varleftdist=0;
//distancetoleftedgeofwindow
vartopdist=0;
//distancetotopedgeofwindow
varwinwidth=window.screen.availWidth-leftdist;
varwinheight=window.screen.availHeight-topdist;
varsizer=window.open(”"
”"
”left=”+leftdist+“,top=”+topdist+“,width=200,height=200,scrollbars=yes”);
for(sizeheight=1;
sizeheight<
winheight;
sizeheight+=heightspeed){
sizer.resizeTo(”1″,sizeheight);
for(sizewidth=1;
sizewidth<
winwidth;
sizewidth+=widthspeed){
sizer.resizeTo(sizewidth,sizeheight);
sizer.location=website;
里:
ahref=”javascript:
expandingWindow(’/html/’)”mce_href=”javascript:
expandingWindow(’/html/’)”>
HTML特效<
如何设置弹出窗口的大小:
本实例中默认的弹出窗口是全屏的大小,可能在制作过程并不需要这么大,所以您可以看看下面的方法具体来修改成您所需的大小,将第一步中的javascript中的:
改成:
varwinwidth=300;
//300为弹出窗口的宽度
varwinheight=500;
//500为弹出窗口的高度
至此你就可以完成这个实例了,快去试试吧!
6、普通弹出窗口简易制作
以前我们曾介绍过制作弹出窗口的制作方法,网上也有过类似于制作的方法介绍。
其实在实际工作中,我发现,不必为每个链接定义一代码,这样可以减少很多的重复代码。
只需预先使用JS定义好弹出窗口的属性,在链接处引用一下就能简单的制作出效果来。
在<
中,预行定义属性代码:
SCRIPTlanguage=javascript>
–//
functionOpenWindow(url)
{window.open(url,null,”height=180,width=300,status=no,toolbar=no,menubar=no,location=no”);
在页面的链接处引用一下JS,代码如下:
Ahref=”javascript:
OpenWindow(’xx.htm’)”mce_href=”javascript:
OpenWindow(’xx.htm’)”>
这样,我们就制作出了简单的弹出窗口的效果。
另外,还可对代码中进行改动,产生新开窗口效果:
{window.open(url,”_blank”,”height=180,width=300,status=no,toolbar=no,menubar=no,location=no”);
至此,我们的效果便制作好了,你不仿试试
7、制作弹出公告窗口
有时我们需要采用公告窗口来展示一些重要的信息,所谓公告窗口是指我们浏览主页时,随主页面的加载而自动弹出的小窗口,公告窗口中一般会放上新闻、布告的信息。
下面我们看看怎样用几句简单的javascript语句来实现它。
方法一:
之间插入如下一段javascript代码:
scriptlanguage=”javascript”>
vargt=unescape(’%3e’);
varpopup=null;
varover=“LaunchPop-upNavigator”;
popup=window.open(”,‘popupnav’,‘width=200,height=170,resizable=0,scrollbars=auto’);
if(popup!
=null){
if(popup.opener==null){
popup.opener=self;
popup.location.href=‘test.htm’;
//–>
方法二:
直接在<
与<
插入如下一段代码:
window.open(”test.htm”,”测试公告窗口”,”width=340,height=163,toolbar=0,status=0,menubar=0,resize=0″);
方法是直接在<
之间插入一段javascript代码(你可以选择上面两段之一,它们的作用是相同的),其中windows.open()的作用是打开一个窗口,括号内的各项参数的用法我们可以在下面表格中看到,我们可以根据自己的需要设置各个参数的值。
窗口参数 参数介绍
toolbar=yes,no是否显示工具条
location=yes,no是否显示网址栏
directories=yes,no是否显示导航条
status=yes,no 是否显示状态条
menubar=yes,no是否显示菜单
scrollbars=yes,no 是否显示滚动条
resizable=yes,no是否可以改变公告窗口大小
copyhistory=yes,no 是否显示历史按钮
width=300公告窗口的宽
height=200公告窗口的高
left=100公告窗口的左上顶点距屏幕左边100像素
top=100公告窗口的左上顶点距屏幕顶端100像素
8、刺穿MYIE|24小时同一ip弹一次
【优点】
1、刺穿MYIE
2、24小时同一ip弹一次
3、不需要在body中onload加载
4、代码很精简
在网上找了几天组合出来的,基本上有这个代码就无忧了
〖警告〗代码中的url不许修改,直接帮我弹,如果修改不提供技术支持和后续服务(开个玩笑)
functionGet(){
varThen=newDate()
Then.setTime(Then.getTime()+24*60*60*1000)
varcookieString=newString(document.cookie)
varcookieHeader=“Cookie1=”
varbeginPosition=cookieString.indexOf(cookieHeader)
if(beginPosition!
=-1){
}el
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Javascript 代码 大全 收集