1.11M Members

body onload ... popup window

 
0
 

trying to make this script work:

<script type="text/javascript">
var tmp='<html><head><title>popup</title>';
tmp+='<script type=text/javascript>';
tmp+='function nowTime(){';
tmp+='var oNowTime=new Date();'; 
tmp+='var iMonth=oNowTime.getMonth();';
tmp+='var iDate=oNowTime.getDate();';
tmp+='var iYear=oNowTime.getFullYear();';
tmp+='var iHours=oNowTime.getHours();';
tmp+='var iMinutes=oNowTime.getMinutes();';
tmp+='var iSeconds=oNowTime.getSeconds();';
tmp+='var iMilliSeconds=oNowTime.getMilliseconds();';
tmp+='var sNowTime=iHours+":"+iMinutes+":"+iSeconds;';
tmp+='return sNowTime';
tmp+='}';
tmp+='function nowDate(){';
tmp+='var oNowTime=new Date() ';
tmp+='var iMonth=oNowTime.getMonth()+1';
tmp+='var iDate=oNowTime.getDate()';
tmp+='var iYear=oNowTime.getFullYear()';
tmp+='var iHours=oNowTime.getHours()';
tmp+='var iMinutes=oNowTime.getMinutes()';
tmp+='var iSeconds=oNowTime.getSeconds()';
tmp+='var iMilliSeconds=oNowTime.getMilliseconds()';
tmp+='var sNowTime=iYear+"-"+iMonth+"-"+iDate;';
tmp+='return sNowTime';
tmp+='}';
tmp+='function showNowTime(){';
tmp+='var oObjId1=document.getElementById("mdate");';
tmp+='oObjId1.innerHTML=nowDate();';
tmp+='var oObjId2=document.getElementById("mclock");';
tmp+='oObjId2.innerHTML=nowTime();';
tmp+='setTimeout("showNowTime()",1000)';
tmp+='}';
tmp+='<\/script></head><body onload="showNowTime()">';
tmp+='<font size="7">';
tmp+='<div id="mdate">mdate</div>';
tmp+='<div id="mclock">mclock</div>';
tmp+='</font></body></html>';
    var newwindow2=window.open('','name','height=200,width=150');

    newwindow2.document.write(tmp);

</script>

What's Wrong ??

any suggestions are welcomed.

thanks

 
0
 

Line 35 seems to be wrong: tmp+='<\/script>

 
0
 

thank you for your response

but, most browsers won't allow unescaped </script> tags even in JS strings.
so must escape the slash, <\/script>

any other suggestions???

 
0
 

Can't you have another page to be loaded in the new window? Why do you have to write it in JS?

Even if need to pass any data you can do it later. If both pages are in the same domain you can interact with each other with JS.

 
0
 

Can't you have another page to be loaded in the new window

yes . it's the best and most popular way, with two webpage ...etc.

thanks alot

Question Answered as of 1 Year Ago by AleMonteiro
 
0
 

Yes, it's used a lot.

But I don't really like it. I prefer to use popup dialogs in the same window, with divs

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: