Browser : IE6/IE7.
I want to load a new document into my html modal dialog, either via a form target or a javascript function.
<html> <!-- quirks mode -->
<head>
<script>
function openModal(url) {
if(window.showModalDialog) showModalDialog(url);
else {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
open(url, "", "modal=yes");
} catch (e) {
alert("dialog windows unsupported by browser");
}
}
}
</script>
</head>
<body style="background:red" onload="setTimeout(function(){document.body.style.backgroundColor='white'},100)">
<a href="javascript:openModal(location.href)">Open Modal</a>
<form>
<input type="submit" value="Send Form" />
</form>
<a href="javascript:location.reload()">Reload content</a>
</body>
</html>
In Gecko-based browsers, it works.
In IE, when in the modal dialog window, the form opens a new window (even if I specify the target="_self"
attribute), and the javascript reload() fails silently. If I try to do a location.replace(location.href)
or location.href=_someurl_
, it opens a new window.
So my question : how can I get IE to replace the current document in a modal dialog window?