View Full Version : showmodal window

07-06-2006, 12:06 PM
here is my code in javascript
i am trying to popup a window from the script itself. my ultimate goal is to attain showModalDialog quality to the windowm . i could not replace open with showModalDialog. is there anyother way to attain this quality to my window? plz suggest me here. thanks

function firstPopup() {

myWin= open("", "displayWindow","titlebar=no,width=275,height=200,status=no,titlebar=no,toolbar=no,menubar=no,location=no,directories =no,alwaysRaised=yes,outerWidth=1,outerHeight =1,left=350,top=200");


myWin.document.write("<HTML>" );

myWin.document.write(" <HEAD >");

myWin.document.write(" <style> .message { position:absolute; top:10px; width:255px; height:25px; color: red; border: solid rgb(0,127,164); border-left-style: hidden; border-right-style: hidden; border-bottom-style: hidden; /* orange */ background-color: white ; } .message #button{ position:relative; color: black; visibility: visible; background-color: white ; } .button{ position:relative; color: black; border-width: 0px; border-style: solid; visibility: hidden; background-color: lightblue; } #myButton { position: absolute; right: 145px; bottom: 35px;} #cancelButton { position: absolute; right: 60px; bottom: 35px;} </style> ");

myWin.document.write(" <script language=\"javascript\" > var imp= null; function impor(){imp='norefresh';} ; function fcl(){ if(imp!='norefresh') { opener.reFreshCurWindow(); }} function func(s){ if(s==\"CONTINUE\"){opener.selectionofbutton(s);self.close();}else{opener.selectionofbutton(s);self.close(); }}function f1(){setInterval (\"window.focus()\",1)}; setTimeout('impor()',359999);</script> " );

myWin.document.write(" <TITLE> CCH WALL STREET - CRN</TITLE> </HEAD>");

myWin.document.write("<BODY bgcolor=white onUnload=\"fcl()\" onBlur=\"window.focus()\" onload=\"f1()\" ><form name=\"bobz\" method=\"get\" action=\"\"> <div class=\"message\"> <div id=\"button\" class=\"button\" > <h4> your CCH Research Network session will time-out in a few minutes due to inactivity. If you would like to continue your research, click the appropriate button below <h4> </div> </div> <div id=\"myButton\"> <input type=\"button\" name=\"CONTINUE\" value=\"CONTINUE\" onClick=\"impor(this.name) ,func(this.name)\"></div> <div id=\"cancelButton\"> <input type=\"button\" name=\"LOG OFF\" value=\"LOG OFF\" onClick=\"return func(this.name)\"></div></form>");




setTimeout ('myWin.close()', 360000);
lastwin = setTimeout ("finalwindow()",360000);


07-06-2006, 12:16 PM
Well I wrote this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function loadit(url,wid,hgt)
var sw = (screen.width - wid) / 2;
var sh = (screen.height - hgt) / 2;
if (window.showModalDialog)
win = window.showModalDialog(url,'dialogHeight='+hgt+',dialogWidth='+wid+'');
win = window.open(url,'win','height='+hgt+',width='+wid+',top='+sh+',left='+sw+'');

<a href="http://www.yahoo.com" onClick="loadit(this.href,400,400);return false">yahoo</a>
It will use showModalDialog if the browser supports it, if not, it will use window.open but your problem seems to be that you have used the open() function twice in succession. Get rid of the part in bold here

myWin= open("", "displayWindow","titlebar=no,width=275,height=200,status=no,titlebar=no,toolbar=no,menubar=no,location=no,directories =no,alwaysRaised=yes,outerWidth=1,outerHeight =1,left=350,top=200");


07-06-2006, 01:34 PM
u have not understood my question properly.