...

View Full Version : ModalWindow Redirect



christrinder
02-22-2007, 12:26 PM
Hi all,

I have in my web application, a modal window popup (I know people don't like these, but it is only for an intranet). When they click a value, I want to redirect (using javascript) to another page carrying the value with me. I have used the following code, but when you click the link, it opens a new window, despite the fact I have set the base target as 'self'. Any ideas?

<script type="text/javascript">
function Select(strValue)
{
window.location = "/Page.aspx?Value="+ strValue;
}
</script>
<base target="_self">

glenngv
02-22-2007, 10:33 PM
Modal dialogs inherent behavior is that a new window is opened for redirecting links and form submission. I don't know the reason behind that.

Try this workaround:

<head>
<script type="text/javascript">

window.name = "modalWin";

function Select(strValue)
{
window.open("/Page.aspx?Value="+ strValue, window.name);
}
</script>
</head>
If you are also submitting the form, you can set the form target to whatever you put in the window.name so that it won't open a new window.

<form ... target="modalWin">
...
<input type="submit" value="Submit" />
</form>

christrinder
02-23-2007, 05:11 PM
Finally got around to trying this... worked a treat!

Thanks very much! :thumbsup:

glenngv
02-23-2007, 10:17 PM
Glad to be of help. :)
Discovered that trick in my past project where my colleagues used to create framesets in the modal dialog to avoid new window from opening.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum