showModalDialog; Öffnet ein Neues Fenster im IE
Bitte siehe update (11/27) unter
Habe ich ein modal-Fenster gestartet wird mit content in einem iframe (ASP webforms-Anwendung). Wir müssen die modal-redirect zu einer anderen Seite, aber nicht innerhalb des iFrames aus Sicherheitsgründen (Paypal-Verarbeitung Seite). In Chrome und IE im standards-Modus, haben wir den code richtig, dass Veränderungen des modal URL auf der rechten Seite ein. Aber im Kompatibilitätsmodus, die Umleitung bewirkt, dass ein neues modales Fenster zu öffnen mit der korrekten URL. Wie können wir verhindern, dass es ein neues Fenster zu öffnen und eigentlich umleiten?
Dies ist unsere aktuelle code:
dialog.redirect = function (location, ignoreFrames) {
///<summary>Redirects the dialog to a new URL</summary>
///<param name="location" type="String"></param>
///<param name="ignoreFrames" type="Boolean">If true, the dialog's URL will be changed instead of any parent frame URLs</param>
if (ignoreFrames === undefined) {
ignoreFrames = true;
}
if (ignoreFrames === true) {
if (window.top) {
//Chrome and IE9+
window.top.document.location.replace(location);
} else {
//This was a supposed fix but it did not change the outcome
//<IE8 and compat mode
var redirectLink = document.createElement("a");
redirectLink.href = location;
document.body.appendChild(redirectLink);
redirectLink.click();
}
} else {
window.document.location.replace(location);
}
};
Update 11/27, mit beispielsweise der Frage:
Interaktives Beispiel (Erfordert IE10+ - oder-alle guten browser)
Der folgenden ist ein Beispiel für das Problem, mit allem eingerichtet, wie wir es haben. Wenn das modal wird im IE Kompatibilitäts-Modus, es öffnet sich ein neues Fenster, anstatt dass Sie modal. Befestigung die Seite im Kompatibilitätsmodus ist nicht einfacher Prozess, wie unsere Anwendung basiert auf Kompatibilitätsmodus und der äußeren modalen Seite wird sehr Häufig genutzt, überall. Anzeigen der Seite (main.html) in FireFox (Chrome hat die domain-Sicherheit-Ausgabe), es funktioniert wie erwartet; die modal ist komplett umgeleitet auf die neue Seite.
main.html
<html>
<head></head>
<body>
<a href="javascript:window.showModalDialog('modal.html', self, 'status:no;resizable:yes;help:no;scroll:no;width:1000;height:600')">Open Modal</a>
</body>
</html>
modal.html
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class=""> <!--<![endif]-->
<head>
<title id="tagTitle"></title>
</head>
<body style="margin:0px">
<form name="Form1" method="post" action="" id="Form1">
<strong>modal.html</strong><br />
<iframe frameborder="1" src="frame.html" scrolling="yes"></iframe>
</form>
</body>
</html>
frame.html
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6" xmlns="http://www.w3.org/1999/xhtml"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7" xmlns="http://www.w3.org/1999/xhtml"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8" xmlns="http://www.w3.org/1999/xhtml"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9" xmlns="http://www.w3.org/1999/xhtml"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html class="" xmlns="http://www.w3.org/1999/xhtml">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>
<body>
<strong>frame.html</strong><br />
<a href="javascript:void(0)" onclick="redirectToCart();" title="My Cart">Trigger Redirect</a>
<script type="text/javascript">
var redirect = function (location, ignoreFrames) {
///<summary>Redirects the dialog to a new URL</summary>
///<param name="location" type="String"></param>
///<param name="ignoreFrames" type="Boolean">If true, the dialog's URL will be changed instead of any parent frame URLs</param>
if (ignoreFrames === undefined) {
ignoreFrames = true;
}
if (ignoreFrames === true) {
window.top.document.location.replace(location); //IE will create a new window at this point, instead of changing the modal's URL
} else {
window.document.location.replace(location);
}
};
function redirectToCart() {
redirect('anotherpage.html', true); //Change this to false to see just the inner frame's URL change
}
</script>
</body>
</html>
anotherpage.html
<html>
<head>
</head>
<body>
<strong>anotherpage.html</strong><br />
Success
</body>
</html>
War nur in den Prozess der überprüfung!
InformationsquelleAutor Jason Kaczmarsky | 2013-11-25
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ihrem Problem entsteht, weil Sie mit
showModalDialog
die stellt dieses Verhalten bei der VerwendungIE
.Können Sie darüber Lesen Sie hier:
showModalDialog Öffnet sich ein Neues Fenster
Wenn Sie weiterhin verwenden möchten
showModalDialog
hier ist eine Arbeit um:modal.html
frame.html
Beispiel
http://plnkr.co/edit/ClxlWqkzBmTy93kJzuru?p=preview
InformationsquelleAutor Trevor