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

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

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???

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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.