Thursday, July 3, 2008

Tips: Session is lost when using showModalDialog.

This is a known problem of the IE when one is calling the "showModalDialog" in his/her JavaScript codes. The workaround for this problem is to add "<base target="_self" />" to the head section of the dialog page.

3 comments:

Karunakaran said...

I did try this, I added the base target="_self" to pop up window it does not seem to work

Using IE7

Leonwoo said...

Hi Karunakaran,
I am not too sure how you did it but below is an example that you can use.

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Web Page</title>

<base target="_self" />

</head>

<body>

<form id="form1" runat="server">

<div>

</div>

</form>

</body>

</html>


function ShowModalWindow( url, winName, width, height)

{

xposition=0; yposition=0;

if ((parseInt(navigator.appVersion) >= 4 ))

{

xposition = (screen.width - width) / 2;

yposition = (screen.height - height) / 2;

}

theproperty= "dialogWidth:" + width + "px;"

+ "dialogHeight:" + height + "px;"

+ "location:0;"

+ "menubar:0;"

+ "resizable:0;"

+ "scrollbars:0;"

+ "status:0;"

+ "titlebar:0;"

+ "toolbar:0;"

+ "hotkeys:0;"

+ "screenx:" + xposition + ";" //only for Netscape

+ "screeny:" + yposition + ";" //only for Netscape

+ "left:" + xposition + ";" //IE

+ "top:" + yposition; //IE



var str= window.showModalDialog( url,winName, theproperty);
return str;

}

Anonymous said...

This doesnt work :(