javascript - how to pop a dialog from a website meanwhile by refreshing this website,the dialog will NOT disappear? -




here detail of question:

there ia website called a. pressing button on website a, dialog shows up.after 10 seconds,the dialog disappears.my question is:the website keeps refreshing every 3 seconds,so everytime press button,the dialog can shown less 3 seconds because dialog frame disappear after website refreshing itself.

the website has keep refresh newest information,the time intercal can not changed,which 3 sec.but want keep dialog 10 seconds,long enough user see.

the reason why didn't use ajax used python creat html when there new information.but after html created,the previous website can not discover such change of html.only refreshing time can browser load newest html.but i'll consider use ajax if there no other ways.

also found other resourece code web of dialogs disappear after refreshing.

can have idea share? appreciate help.thanks much!

here code:

 <html>  <head>  <meta http-equiv="refresh" content="3">    <title>javascript closing dialog auto.</title>  <meta  http-equiv="content-type" content="text/html;charset=gb2312">  </head>  <body>     <input type="button" value="pop" onclick="alert('close  after 10 sec')">    <script>  function alert(str) {        var msgw,msgh,bordercolor;        msgw=350;        msgh=80;       titleheight=25;        bordercolor="#336699";        titlecolor="#99ccff";        var swidth,sheight;      swidth = document.body.offsetwidth;    sheight = document.body.offsetheight;        var bgobj=document.createelement("div");    bgobj.setattribute('id','alertbgdiv');    bgobj.style.position="absolute";    bgobj.style.top="0";    bgobj.style.background="#e8e8e8";    bgobj.style.filter="progid:dximagetransform.microsoft.alpha(style=3,opacity=25,finishopacity=75";    bgobj.style.opacity="0.6";    bgobj.style.left="0";    bgobj.style.width = swidth + "px";    bgobj.style.height = sheight + "px";    bgobj.style.zindex = "10000";    document.body.appendchild(bgobj);     var msgobj = document.createelement("div")    msgobj.setattribute("id","alertmsgdiv");    msgobj.setattribute("align","center");    msgobj.style.background="white";    msgobj.style.border="1px solid " + bordercolor;    msgobj.style.position = "absolute";    msgobj.style.left = "50%";    msgobj.style.font="12px/1.6em verdana, geneva, arial, helvetica, sans-serif";     msgobj.style.marginleft = "-225px";    msgobj.style.top = document.body.scrolltop+(window.screen.availheight/2)-150 +"px";    msgobj.style.width = msgw + "px";    msgobj.style.height = msgh + "px";    msgobj.style.textalign = "center";    msgobj.style.lineheight ="25px";    msgobj.style.zindex = "10001";    document.body.appendchild(msgobj);     var title=document.createelement("h4");    title.setattribute("id","alertmsgtitle");    title.setattribute("align","left");    title.style.margin="0";    title.style.padding="3px";    title.style.background = bordercolor;    title.style.filter="progid:dximagetransform.microsoft.alpha(startx=20, starty=20, finishx=100, finishy=100,style=1,opacity=75,finishopacity=100);";    title.style.opacity="0.75";    title.style.border="1px solid " + bordercolor;    title.style.height="18px";    title.style.font="12px verdana, geneva, arial, helvetica, sans-serif";    title.style.color="white";    title.innerhtml="info";    document.getelementbyid("alertmsgdiv").appendchild(title);     var txt = document.createelement("p");    txt.setattribute("id","msgtxt");    txt.style.margin="16px 0";    txt.innerhtml = str;    document.getelementbyid("alertmsgdiv").appendchild(txt);     window.settimeout("closewin()",10000);      }    function closewin() {        document.body.removechild(document.getelementbyid("alertbgdiv"));        document.getelementbyid("alertmsgdiv").removechild(document.getelementbyid("alertmsgtitle"));        document.body.removechild(document.getelementbyid("alertmsgdiv"));    }  </script>  </body>     </html>  

i think need ajax,it can refresh data not refresh whole page a. here's intro js here! can use jquery solve here!





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -