showModalDialog; Ouvre une Nouvelle Fenêtre dans IE

Veuillez consulter la mise à jour (11/27) ci-dessous

J'ai une fenêtre modale qui est lancé avec son contenu dans une iframe (ASP formulaires de demande). Nous avons besoin d'avoir le modal rediriger vers une autre page, mais il ne peut pas être à l'intérieur de l'iframe pour des raisons de sécurité (Paypal page de traitement). Dans Chrome et IE normes de la mode, nous avons un code correctement les changements modaux de l'URL vers la droite. Toutefois, dans le mode de compatibilité, la redirection provoque une nouvelle fenêtre modale pour l'ouvrir avec l'URL est correcte. Comment pouvons-nous empêcher l'ouverture d'une nouvelle fenêtre et fait la redirection?

C'est notre code actuel:

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);
        }
    };

Mise à jour 11/27, avec l'exemple du problème:

Interactive Exemple (Nécessite IE10+ ou tout bon navigateur)

L'exemple suivant est un exemple de la question, avec tout mis en place la façon dont nous l'avons. Lorsque le modal est dans IE mode de compatibilité, il ouvre une nouvelle fenêtre au lieu de rediriger l'modal. La fixation de la page en mode de compatibilité n'est pas un processus facile, notre application s'appuie sur le mode de compatibilité et de l'extérieur modal page est largement utilisé partout. L'affichage de la page (main.html) dans FireFox (Chrome a ce domaine problème de sécurité), il fonctionne comme prévu; le modal est complètement redirigé vers la nouvelle page.

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>
Puis-je obtenir du feedback sur ma réponse? N'a que le résoudre pour vous?
A été juste en train de vérifier!

OriginalL'auteur Jason Kaczmarsky | 2013-11-25