请教一个弹出窗口的问题

问题描述

我这里有一个比较好的弹出窗口的代码,类似新浪博客里的弹出窗口效果,现在我想24小时只弹出一次该窗口,请问如何实现?下面是主html页面的代码:<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-type"content="text/html;charset=gb2312"/><title>类似新浪博客右下角弹出浮动层窗口可最小化可关闭_懒人建站http://www.51xuediannao.com</title><metaname="keywords"content="HTML+CSS模板,HTML+CSS教程,HTML+CSS导航菜单,FLASH焦点图,网页特效"/><metaname="description"content="懒人建站为您提供-HTML+CSS模板,HTML+CSS教程,JS广告代码,HTML+CSS导航菜单,FLASH焦点图片,国外网页设计欣赏与模板和CSS技巧。"/></head><body><script>/**---------------------------------------------------------------------------*/{varua=navigator.userAgent;var$IE=(navigator.appName=="MicrosoftInternetExplorer");var$IE5=$IE&&(ua.indexOf('MSIE5')!=-1);var$IE5_0=$IE&&(ua.indexOf('MSIE5.0')!=-1);var$Gecko=ua.indexOf('Gecko')!=-1;var$Safari=ua.indexOf('Safari')!=-1;var$Opera=ua.indexOf('Opera')!=-1;var$Mac=ua.indexOf('Mac')!=-1;var$NS7=ua.indexOf('Netscape/7')!=-1;var$NS71=ua.indexOf('Netscape/7.1')!=-1;if($Opera){$IE=true;$Gecko=false;$Safari=false;}if($IE5){$IE=true;$Gecko=false;$Safari=false;}}function$_t(root,tag,id){varar=root.getElementsByTagName(tag);for(vari=0;i<ar.length;i++){if(ar[i].id==id)returnar[i];}returnnull;}function_(root){varids=arguments;vari0=0;if(typeof(root)=='string')root=document;elsei0=1;for(vari=i0;i<ids.length;i++){vars=root.getElementsByTagName("*");varhas=false;for(varj=0;j<s.length;j++){if(s[j].id==ids[i]){root=s[j];has=true;break;}}if(!has)returnnull;}returnroot;}//utilfunction$dele(o,fn,rv){varr=function(){vars=arguments.callee;varargs=[];for(vari=0;i<s.length;i++)args[i]=s[i];varargStr=args.join(",");if(argStr.length>0)argStr=","+argStr;varcallStr="s.thiz[s.fn]("+argStr+")";varv=eval(callStr);if(s.rv!=null){returns.rv;}else{returnv;}}r.thiz=o;r.fn=fn;r.rv=rv;returnr;}function$ge(e){if(e!=null)returne;if($IE){returnwindow.event;}elsereturne;}/***geteventforaelement;*/function$gte(e,ev){if(!e.getElementById)e=e.ownerDocument;if($IE){returnev!=null?ev:e.parentWindow.event;}else{returnev;thrownewError("thismethodcanonlyexecuteinIE");}}function$addEL(n,e,l,b){if($IE){if(n["$__listener_"+e]==null){varlst=function(e){varf=arguments.callee;varar=f.fList;e=$ge(e);for(vari=0;i<ar.length;i++){ar[i](e);}}lst.fList=[];n["$__listener_"+e]=lst;n["on"+e]=n["$__listener_"+e];}varfList=n["$__listener_"+e].fList;fList[fList.length]=l;}else{n.addEventListener(e,l,b);}}function$cancelEvent(e){if($IE){e.returnValue=false;e.cancelBubble=true;}elsee.preventDefault();};function$cpAttr(o,p){for(variinp){vars=p[i];o[i]=s;}returno;}function$getValue(v,d){returnv==null?d:v;}var$gv=$getValue;var$dom={parseInt:function(s){if(s==null||s==''||typeof(s)=='undefined')return0;returnparseInt(s);},getClientSize:function(n){if($IE){//ts("thisisie");vars={x:n.clientLeft,y:n.clientTop};s.l=s.x;s.t=s.y;s.r=n.clientRight;s.b=n.clientBottom;s.w=n.clientWidth;s.h=n.clientHeight;//tr("calculatedclientsize");returns;}else{vart=n.style;if(t.borderLeftWidth.length==0||t.borderTopWidth.length==0||t.borderRightWidth.length==0||t.borderBottomWidth.length==0){varl=n.offsetWidth;t.borderLeftWidth="0px";l-=n.offsetWidth;varr=n.offsetWidth;t.borderRightWidth="0px";r-=n.offsetWidth;varo=n.offsetHeight;t.borderTopWidth="0px";o-=n.offsetHeight;varb=n.offsetHeight;t.borderBottomWidth="0px";b-=n.offsetHeight;t.borderLeftWidth=l+"px";t.borderTopWidth=o+"px";t.borderRightWidth=r+"px";t.borderBottomWidth=b+"px";vars={l:l,r:r,t:o,b:b,x:l,y:o};returns;}else{vars={x:this.parseInt(n.style.borderLeftWidth),y:this.parseInt(n.style.borderTopWidth),r:this.parseInt(n.style.borderRightWidth),b:this.parseInt(n.style.borderBottomWidth)};s.l=s.x;s.t=s.y;returns;}}},

解决方案

解决方案二:
getSize:function(n,withMargin){varc={x:n.offsetWidth!=null?n.offsetWidth:0,y:n.offsetHeight!=null?n.offsetHeight:0};//c.x=this.parseInt(c.x);//c.y=this.parseInt(c.y);//tr("getsizefor:"+n.id);//tra(c);if(withMargin){varm=this.getMargin(n);c.x+=m.l+m.r;c.y+=m.t+m.b;}//tra(m);//tr("getsizefor:"+n.id);//tra(c);returnc;},setSize:function(elmt,x,y,withMargin){//tf("$dom::setSize");//if(elmt==undefined||elmt.style.display=="none")return;if($IE){if(withMargin){varm=this.getMargin(elmt);x-=m.l+m.r;y-=m.t+m.b;}elmt.style.width=x;elmt.style.height=y;}else{varclientSize=this.getClientSize(elmt);vardx=clientSize.l+clientSize.r;vardy=clientSize.t+clientSize.b;elmt.style.width=x-dx+"px";elmt.style.height=y-dy+"px";}},/***getthecontextpositionrelativetoitsparent.*/getPosition:function(elmt,withMargin){varc;c={x:elmt.offsetLeft,y:elmt.offsetTop};//c.x=this.parseInt(c.x);//c.y=this.parseInt(c.y);if(withMargin){varm=this.getMargin(elmt);c.x-=m.l;c.y-=m.t;}returnc;},setPosition:function(elmt,x,y,withMargin){//tf("$dom::setPosition");if(withMargin){//varm=this.getMargin(elmt);//x-=m.l;//y-=m.t;}elmt.style.left=x+"px";elmt.style.top=y+"px";},setAlpha:function(n,a){return;n.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+a*100+");";n.style.opacity=a;n.style.MozOpacity=a;}}var$motion={smooth:function(s,e,t){if(t>1)t=1;return(e-s)*t+s;}}functionPopUp(id,config){this.id=id;varc=this.config=config;c.width=$gv(c.width,300);c.height=$gv(c.height,200);c.bottom=$gv(c.bottom,0);c.right=$gv(c.right,20);c.display=$gv(c.display,true);c.contentUrl=$gv(c.contentUrl,"");c.motionFunc=$gv(c.motionFunc,$motion.smooth);c.position={x:0,y:0};vart=c.time;t.slideIn=$gv(t.slideIn,10);t.hold=$gv(t.hold,10);t.slideOut=$gv(t.slideOut,10);t.slideIn*=1000;t.hold*=1000;t.slideOut*=1000;this.container=document.body;this.popup=null;this.content=null;this.switchButton=null;this.moveTargetPosition=0;this.startMoveTime=null;this.startPosition=null;this.status=PopUp.STOP;this.intervalHandle=null;this.mm="max";this.imgMin="images/min.gif";this.imgMax="images/max.gif";}//staticmembersPopUp.STOP=0;PopUp.MOVE_DOWN=1;PopUp.MOVE_UP=2;PopUp.SWITCH_TO_MIN=PopUp.MOVE_DOWN|4;PopUp.SWITCH_TO_MAX=PopUp.MOVE_UP|8;var__o={create:function(){vardoc=document;varc=this.config;//createpopupholder&configit.varp=this.popup=doc.createElement("div");this.container.appendChild(p);p.id=this.id;p.style.cssText="position:absolute;z-index:9000;overflow:hidden;border:0pxsolid#f00;";$dom.setSize(p,c.width,c.height);//createpopupcontentholder&configit.vart=this.content=doc.createElement("div");p.appendChild(t);t.id=this.id+"_content";t.style.cssText="position:absolute;z-index:1;overflow:hidden;";$dom.setSize(t,c.width,c.height);$dom.setPosition(t,0,0);//addc.position.y=c.height;//addthis.onresize();//add//$dom.setPosition(t,0,c.height);//hideitatfirst//createcontentholder'scontent.//aclosebutton&aniframeforloadingexternalcontent.t.innerHTML="<aid='closeButton'href='#'></a>"+"<aid='switchButton'href='#'></a>"+"<iframeid='"+this.id+"_content_iframe'src="+c.contentUrl+"frameborder=0scrolling=nowidth='100%'height='100%'style='height:100%'></iframe>";varsBtn=this.switchButton=$_t(t,'a',"switchButton");sBtn.style.cssText='position:absolute;z-index:2;\font-size:0px;line-height:0px;\left:220px;top:6px;width:15px;height:15px;\background-image:url("images/min.gif");';$addEL(sBtn,"click",$dele(this,"switchMode"),true);$addEL(sBtn,"click",$cancelEvent,true);varbtn=$_t(t,'a',"closeButton");btn.style.cssText='position:absolute;z-index:2;\font-size:0px;line-height:0px;\left:240px;top:6px;width:15px;height:15px;\background-image:url("images/close.gif");';$addEL(btn,"mouseover",function(e){$dom.setAlpha(this,0.4);},true);$addEL(btn,"mouseout",function(e){$dom.setAlpha(this,1);},true);$addEL(btn,"click",$dele(this,"hide"),true);$addEL(btn,"click",$cancelEvent,true);varcontainer=$IE?document.body:document.documentElement;$addEL(document.body,"resize",$dele(this,"onresize"),true);this.__hackTimer=window.setInterval("__popup.onresize()",50);$addEL(container,"scroll",$dele(this,"onresize"),true);//initializepositionatonce.this.onresize();},show:function(){if(!this.config.display)return;this.moveTargetPosition=0;this.status=PopUp.MOVE_UP;this.startMove();},hide:function(){this.moveTargetPosition=this.config.height;this.status=PopUp.MOVE_DOWN;this.startMove();},minimize:function(){//alert("minimize");this.mm="min";this.moveTargetPosition=this.config.height-28;this.status=PopUp.SWITCH_TO_MIN;this.startMove();vars=this.switchButton.style;varbg=s.backgroundImage;if(bg.indexOf(this.imgMin)>-1){bg=bg.replace(this.imgMin,this.imgMax);s.backgroundImage=bg;}},maximize:function(){//alert("maximize");if(!this.config.display)return;this.mm="max";this.moveTargetPosition=0;this.status=PopUp.SWITCH_TO_MAX;this.startMove();vars=this.switchButton.style;varbg=s.backgroundImage;if(bg.indexOf(this.imgMax)>-1){bg=bg.replace(this.imgMax,this.imgMin);s.backgroundImage=bg;}},delayHide:function(){window.setTimeout("__popup.hide()",this.config.time.hold);},delayMin:function(){window.setTimeout("__popup.minimize()",this.config.time.hold);},switchMode:function(){//alert("switch");if(this.mm=="min"){this.maximize();}else{this.minimize();}},startMove:function(){this.stopMove();this.intervalHandle=window.setInterval("__popup.move()",100);this.startMoveTime=newDate().getTime();//this.startPosition=$dom.getPosition(this.content).y;//parseInt(this.content.style.top);this.startPosition=this.config.position.y;},stopMove:function(){if(this.intervalHandle!=null)window.clearInterval(this.intervalHandle);this.intervalHandle=null;},move:function(){vart=newDate().getTime();t=t-this.startMoveTime;vartotal=this.status&PopUp.MOVE_UP?this.config.time.slideIn:this.config.time.slideOut;vary=this.config.motionFunc(this.startPosition,this.moveTargetPosition,t/total);//this.content.style.top=y+"px";this.config.position.y=y;this.onresize();if(t>=total){this.onFinishMove();}},onFinishMove:function(){this.stopMove();//this.content.style.top=this.moveTargetPosition+"px";if(this.status==PopUp.MOVE_UP&&this.config.time.hold>0){this.delayMin();}else{if(this.__hackTimer!=null)window.clearInterval(this.__hackTimer);}this.status=PopUp.STOP;},onresize:function(){varc=this.config;//vart=document.documentElement;vart=document.body;vardx=t.clientWidth+t.scrollLeft;vardy=t.clientHeight+t.scrollTop;varx=dx-c.right-c.width;vary=dy-c.bottom-c.height+c.position.y;$dom.setPosition(this.popup,x,y);$dom.setSize(this.popup,c.width,c.height-c.position.y);}}$cpAttr(PopUp.prototype,__o);
解决方案三:
functionreadCookie(name){varcookieValue="";varsearch=name+"=";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;cookieValue=unescape(document.cookie.substring(offset,end))}}returncookieValue;}functionwriteCookie(name,value,hours){varexpire="";if(hours!=null){expire=newDate((newDate()).getTime()+hours*3600000);expire=";expires="+expire.toGMTString();}document.cookie=name+"="+escape(value)+expire+";path=/";}/***mainfunctiontoconfigthepop-upwindow&runit.*webdeployerchangecodesheretomanipultepopupsperformance.*&shouldnotchangecodesoutofthisfunction.*/functionjob(){/***configobject*/varcfg={//width&heightofthepopupwindow,thesevaluesshouldbedetermineddebpendedoninnercontents.width:260,height:190,//distancetothebottom&therightedge.bottom:2,right:19,//switchofdisplayingthepopupdisplay:true,//contenturlcontentUrl:"51xuediannao.com.htm",//timeconfiguration,insecondstime:{slideIn:1,hold:60,slideOut:1}}//atwhattimethepopupshoulddisplay,inhours:0~23,//thenumberafteraddsymbolmeansafterhowmanythehourstodisplaypopupforthenexttime.vardisplayTimeList=["15+1"];//thepopupdisplayseachtimethiepagereloadoronlyonceatthefirsttimepageloaded.//once/eachTimevardisplayMode="once";//vardisplayMode="eachTime";//cookienamestoringthenexttimetodisplaypopupvarcookieName="sina_blog_popup_next_display_time";/***---------------------fromherebelow,thecodesshouldNOTbemodified.*/varhours={};vardelays=[];for(vari=0;i<displayTimeList.length;i++){varo=displayTimeList[i];varar=o.split("+");vart=parseInt(ar[0]);for(varm=0;m<ar.length-1;m++){ar[m]=ar[m+1];}hours[t]=true;for(varj=0;j<ar.length;j++){hours[t+parseInt(ar[j])]=true;}}displayTimeList=[];for(variinhours){vars=parseInt(i);if(isNaN(s))continue;displayTimeList[displayTimeList.length]=s;}displayTimeList=displayTimeList.sort();//alert(displayTimeList);varpp=newPopUp("xp",cfg);window.__popup=pp;pp.create();//display:varn=readCookie(cookieName);if(displayMode=="eachTime")pp.show();else{vartm=newDate().getTime();if(n==null||tm>n){pp.show();//getnextdisplaytimevarhr=newDate().getHours();varf=60*60*1000;varl=displayTimeList.concat(),len=l.length;for(vari=0;i<len;i++)l[len+i]=l[i]+24;for(vari=0;i<l.length&&hr>=l[i];i++);vardt=newDate();dt.setHours(l[i]>23?l[i]-24:l[i]);varnextTime=dt.getTime();if(l[i]>23)nextTime+=f*24;writeCookie(cookieName,nextTime,1);}}}functiondoit(){if(document.readyState=='loaded'||document.readyState=='complete'){job();}else{window.setTimeout(doit,500);return;}}doit();</script><!--下面只是说明与程序代码无关--><divstyle="width:95%;height:auto;display:block;margin:0auto;margin-top:30px;font-size:10pt;line-height:150%;"><span>本代码由<ahref="http://www.51xuediannao.com"style="color:#F00;">懒人建站网收集整理</a></span><br><ahref="http://www.51xuediannao.com">懒人建站http://www.51xuediannao.com</a><br/><br/><span>我们为您提供-JS代码,网页图标,网页欣赏模板,SEO优化和各种建站技巧;</span><br/><span>懒人建站只收录实用和能提高用户体验的代码</span><br/><span>我们只想解放出你的部分写代码时间来思考更高层次的设计,而不是要你懒惰、拼凑。</span></div></body></html>
解决方案四:
这个代码很长,只好分三次粘贴。这个代码实现的功能是每次调用该页面都会出现弹出窗口,如果vardisplayMode="once",则只出现一次,但我想实现24小时弹出一次,不知道将displayMode设为"once"后是不是以后都不弹出了,请大侠指教。
解决方案五:
程序太长了没仔细看不知道楼主弹出窗口关闭按钮会不会写(隐藏)如果你会写就可以在js里编写程序js里有相应的windows.命令自己查查我就不帮你查了然后通过windows命令显示出来
解决方案六:
建议lz去看看jquery...这些代码会精简很多.
解决方案七:
收藏了
解决方案八:
可以通过cookie操作varcookies=document.cookie.split(";");if(cookies.length==0){window.open();vart=newDate();varet=newDate(t.getTime()+24*60*60);document.cookie="haveopen=true;expires="et.toGMTString();}
解决方案九:
程序太长了。。。。。。。。。。。。。。。。
解决方案十:
感觉这样的实现没有什么意义。。。。没有使用价值。。。。。当做学习了。。。。。。。。。。。。
解决方案十一:
maya

时间: 2024-08-01 22:37:27

请教一个弹出窗口的问题的相关文章

对话框-asp.net的一个弹出窗口问题

问题描述 asp.net的一个弹出窗口问题 asp.net下如何实现点击一个按钮弹出一个对话框,上面有名字,年龄等信息,然后输入内容确认后更新到数据库??? 解决方案 一个是用js的showDialog,一个是用jquery ui或者 extjs 或者 easyui的对话框,其实是通过层模拟出来的. 无论什么方式,都是将输入的内容提交到服务器上,服务器插入数据库. 解决方案二: 用层来模拟,如artDialog 或者直接window.open打开另外一个aspx页面传递参数进行读取数据库显示 解

用Dreamweaver mx 2004做弹出窗口

dreamweaver|弹出窗口 我们在浏览一些网页时,经常会看到有的网页弹出一些信息窗口或浏览器窗口来显示一些网站公告或一些广告信息,想知道这些窗口是怎么制作出来的吗?如果你还不曾知道,那么就请看本文如何利用Dreamweaver MX 2004 来制作这些弹出窗口的方法吧! 一.弹出信息窗口 启动Dreamweaver MX 2004,打开要加载弹出窗口的网页或新建一个网页.按下Shift+F3命令,打开行为设置面板. 图1 行为面板 (1)点击"+"号 (2)在弹出的菜单中选择&

跟我学写后台程序---控制弹出窗口---用file access组件技巧实例

access|程序|弹出窗口|后台|技巧|控制 跟我学会用后台程序控制弹出窗口---用file access组件修改文件实例我们经常需要在首页上做一个弹出窗口(其实我很讨厌这个东东),一般的办法是在<body> 中加入这样一句 onLoad="Window.open('new-window.htm','','width=300,height=250')"  其中new-window.htm为新开的窗口网页文件名,后页是宽度和高度,但如果是一会要这个窗口,一会又不要,并且常改

控制弹出窗口---用file access组件技巧实例

access|弹出窗口|技巧|控制 跟我学会用后台程序控制弹出窗口---用file access组件修改文件实例我们经常需要在首页上做一个弹出窗口(其实我很讨厌这个东东),一般的办法是在<body> 中加入这样一句 onLoad="Window.open('new-window.htm','','width=300,height=250')" 其中new-window.htm为新开的窗口网页文件名,后页是宽度和高度,但如果是一会要这个窗口,一会又不要,并且常改这个窗口的内容

Silverlight的弹出窗口--展示

背景 年后来到公司实习,第一个星期没有项目,也就无所事是,此时有一位前辈和我说,他们有一个系统 是基于Silverlight研发的,而其中使用的弹出窗口存在着不少的问题,因此如果可以的话,要我做出一 个弹出窗口的功能,其子元素可以是自定义的任何控件. 我很高兴进入公司才几天就能有这样的任务,每一次我去不同的公司实习,总是能在很短的时间内被 "委以重任(当然更多的是我自己在自恋)"去进行可利用的基础设施的研发,非常感谢从大二开始都一 直如此信任和看得我的各家公司,我想只有在这样的环境中才

向使用MultiView和GridView控件的JavaScript弹出窗口要发送值和从之接收值

介绍 很多时候,我们要在我们的应用程序中创建一个弹出窗口.通常当我们弹出一个窗口 ,我们还要使调用窗口和弹出的窗口进行交互.本文中我将展示如何在一个 ASP.NET 应用程序中创建一个弹出窗口 (使用 JavaScript)和如何从弹出窗口返回值到原始的调用页面并自动引发该页上的按钮的单击事件.另外,我将使用 MultiView 控件和 带分页的GridView 控件. 第一步:创建第一个页面 创建一个新的 ASP.NET 网站,默认情况下您会自动创建 Default.aspx.在该页上添加一个

SWT的弹出窗口如何闪烁

问题描述 我想用SWT做一个弹出窗口当鼠标点击在这个窗口之外的地方的时候这个窗口会闪烁就跟咱们ECLIPSE设置属性的那种弹出窗口一样给用户一个提醒作用不关闭这个弹出窗口就不能进行其他操作但是我改如何能做到让他闪烁呢请高手解答一下 解决方案 解决方案二:没做过,期待解决方案三:你说的这个应该是窗口置顶吧?用样式SWT.ON_TOP就好了解决方案四:SWT.ON_TOP解决方案五:引用2楼yangyun724的回复: 你说的这个应该是窗口置顶吧?用样式SWT.ON_TOP就好了 不是啦,就是个模式

[问题解决]IE中可以将弹出窗口置于最顶层的方法(即使当前焦点不在,比如最小化了那个IE也能弹出来)

你如果用过OWA(Exchange的WEB端程序)就会知道这个功能是相当吸引人的.拷贝所有代码,保存为PopupWindow.html,在IE中运行这个文件,就知道了!:)所有的代码如下:PopupWindow.html<HTML><HEAD><TITLE>位于最顶层的弹出窗口</TITLE><SCRIPT LANGUAGE="JScript">//建立一个弹出窗口var oPopup = window.createPopup

js-EASY UI 弹出窗口 怎么能到获取输入?

问题描述 EASY UI 弹出窗口 怎么能到获取输入? 现在要用纯JS 做一个弹出窗口,窗口中有输入框,用户填写后,确定点击事件获取输入数据 代码如下: <a href="#" class="easyui-linkbutton" onclick="mes1()">弹出输入框</a> <script> function mes1() { $.messager .show({ id : "mes1&quo