2013-11-25 18 views
5

कृपया अद्यतन (11/27) नीचेशोमोडालडियलॉग; खोलता IE में एक नई विंडो

देख मैं शुरू की है कि के साथ एक iframe में सामग्री दी गई है मोडल विंडो (एएसपी webforms आवेदन) है। हमें किसी अन्य पृष्ठ पर मोडल रीडायरेक्ट करने की आवश्यकता है, लेकिन सुरक्षा कारणों (पेपैल प्रोसेसिंग पेज) के कारण यह आईफ़्रेम के भीतर नहीं हो सकता है। क्रोम और आईई मानक मोड में, हमारे पास कोड है जो सही तरीके से मोडल के यूआरएल को सही ढंग से बदलता है। हालांकि संगतता मोड में, रीडायरेक्ट एक नई मोडल विंडो को सही यूआरएल के साथ खोलने का कारण बनता है। हम इसे एक नई विंडो खोलने और वास्तव में पुनर्निर्देशित करने से कैसे रोक सकते हैं?

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

अद्यतन 11/27, मुद्दे के उदाहरण के साथ:

Interactive Example (आवश्यकता IE10 + या किसी भी अच्छे ब्राउज़र)

निम्नलिखित

यह हमारे वर्तमान कोड है इस मुद्दे का एक उदाहरण है, सबकुछ स्थापित है कि हमारे पास यह कैसे है। जब मोडल आईई संगतता मोड में है, तो यह मोडल को पुनर्निर्देशित करने के बजाय एक नई विंडो खुलता है। पेज को संगतता मोड में फिक्स करना एक आसान प्रक्रिया नहीं है, क्योंकि हमारा एप्लिकेशन संगतता मोड पर निर्भर करता है और बाहरी मोडल पेज का उपयोग हर जगह बड़े पैमाने पर किया जाता है। फ़ायरफ़ॉक्स में पृष्ठ (main.html) देख रहा है (क्रोम में वह डोमेन सुरक्षा समस्या है), यह अपेक्षा के अनुसार काम करता है; मोडल पूरी तरह से नए पेज पर रीडायरेक्ट किया गया है।

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> 
+0

मैं अपने जवाब पर कुछ प्रतिक्रिया मिल सकता है? क्या यह आपके लिए हल करता है? – Trevor

+1

बस इसे सत्यापित करने की प्रक्रिया में था! –

उत्तर

7

आपका समस्या तब उत्पन्न होती है क्योंकि आप showModalDialog जो इस व्यवहार का परिचय जब IE का उपयोग कर प्रयोग कर रहे हैं।

आप यहाँ इसके बारे में पढ़ सकते हैं:

modal.html

<head> 
    <base target="_self" /> 
    ... 
</head> 
<body style="margin:0px">  
     .... 
     <a href="anotherpage.html" id="go" style="display:none;"></a> 
    </form> 
</body> 

frame.html

:

showModalDialog Opens a New Window

आप यहाँ showModalDialog का उपयोग जारी रखना चाहते हैं, तो चारों ओर एक काम है

उदाहरण

http://plnkr.co/edit/ClxlWqkzBmTy93kJzuru?p=preview

+1

आह मेरे पास एक झटका था, ऐसा कुछ ऐसा था, लेकिन मुझे कोई सबूत नहीं मिला। धन्यवाद, यह तय है। –

संबंधित मुद्दे