2013-02-01 7 views
6

एक फाइल में, मैं t2.html मेंwindow.opener आईओएस क्रोम में सेट नहीं

<a href="t2.html" target="_blank">go</a> 

है मैं iOS पर सफारी पर

<script> 
document.write(window.opener); 
</script> 

है, और क्रोम पर पर मैक और काफी पर हर दूसरे ब्राउज़र, यह [object Window] प्रिंट करता है जैसा आप उम्मीद करेंगे।

आईओएस पर क्रोम पर, मुझे null मिलता है।

मैं इस विंडो को खोलने वाली विंडो पर कैसे जा सकता हूं?

+0

यहाँ देख - https://code.google.com/p/chromium/मुद्दों/विवरण? आईडी = 136610 – vsync

उत्तर

5

यह एक बड़ी कहानी प्रतीत होता है। के रूप में अगर iframes का अभिभावक संपत्ति संभाल सकता

http://code.google.com/p/chromium/issues/detail?id=136610&q=window.opener&colspec=ID%20Pri%20Mstone%20ReleaseBlock%20OS%20Area%20Feature%20Status%20Owner%20Summary

लेकिन ऐसा लगता है, है, तो हो सकता है आप के लिए एक ओवरले का उपयोग करने के पॉपअप का उपयोग करने से आपके एप्लिकेशन को स्विच कर सकते हैं: यहाँ बगट्रैकर देखें।

+0

एक अद्यतन किया गया है। समस्या तय की गई है। Http: //code.google.com/p/chromium/issues/detail? Id = 136610 # c57 – kane

7

यह कोड उस समस्या को हल करता है जिसके बारे में आप बात कर रहे हैं (विशेष रूप से क्रोम आईओएस के साथ मुद्दों के लिए "पॉप अप" पसंद नहीं है), लेकिन पेपैल एडैप्टिव पेमेंट्स के संदर्भ में जहां यह "पॉप अप" खोलता है और भुगतान के लिए पेपैल पेज पर रीडायरेक्ट करता है ।

कुंजी है करने के लिए है कि आप:

  1. आरंभ
  2. आप विंडो "नाम" के रूप में _blank का उपयोग करना होगा एक बटन/लिंक क्लिक से सीधे विंडो.ओपन (और अपने खुद के चयन नहीं)

मुख्य बात आप चाहते हैं/जरूरत है:

var win; 

//VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone 
    //See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610 
win = window.open(paypalURL,'_blank'); 

//Initiate returnFromPayPal function if the pop up window is closed 
if (win && win.closed) { 
    returnFromPayPal(); 
} 

यहाँ पूर्ण कोड कि y है कहां अनुसरण कर सकते हैं (कुछ भी अनदेखा करें जो आप जो कर रहे हैं उस पर लागू नहीं होता है)।

<div> 
    <?php $payUrl = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=mini&paykey=' . $payKey ?> 

    <button onclick="loadPayPalPage('<?php echo $payUrl; ?>')" title="Pay online with PayPal">PayPal</button> 
</div> 
<script> 
    function loadPayPalPage(paypalURL) 
    { 
     var ua = navigator.userAgent; 
     var pollingInterval = 0; 
     var win; 
     // mobile device 
     if (ua.match(/iPhone|iPod|Android|Blackberry.*WebKit/i)) { 
      //VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone 
       //See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610 
      win = window.open(paypalURL,'_blank'); 

      pollingInterval = setInterval(function() { 
       if (win && win.closed) { 
        clearInterval(pollingInterval); 
        returnFromPayPal(); 
       } 
      } , 1000); 
     } 
     else 
     { 
      //Desktop device 
      var width = 400, 
       height = 550, 
       left, 
       top; 

      if (window.outerWidth) { 
       left = Math.round((window.outerWidth - width)/2) + window.screenX; 
       top = Math.round((window.outerHeight - height)/2) + window.screenY; 
      } else if (window.screen.width) { 
       left = Math.round((window.screen.width - width)/2); 
       top = Math.round((window.screen.height - height)/2); 
      } 

      //VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone 
       //See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610 
      win = window.open(paypalURL,'_blank','top=' + top + ', left=' + left + ', width=' + width + ', height=' + height + ', location=0, status=0, toolbar=0, menubar=0, resizable=0, scrollbars=1'); 

      pollingInterval = setInterval(function() { 
       if (win && win.closed) { 
        clearInterval(pollingInterval); 
        returnFromPayPal(); 
       } 
      } , 1000); 
     } 
    } 

    var returnFromPayPal = function() 
    { 
     location.replace("www.yourdomain.com/paypalStatusCheck.php"); 
     // Here you would need to pass on the payKey to your server side handle (use session variable) to call the PaymentDetails API to make sure Payment has been successful 
     // based on the payment status- redirect to your success or cancel/failed page 
    } 
</script> 
0

यदि आप बच्चे से माता-पिता से मूल्यों को निम्नलिखित कोड का उपयोग करना चाहते हैं।

जोड़ें पैरेंट पृष्ठ के लिए कोड का पालन:

var hidden, state, visibilityChange; 
     if (typeof document.hidden !== "undefined") { 
      hidden = "hidden"; 
      visibilityChange = "visibilitychange"; 
      state = "visibilityState"; 
     } else if (typeof document.mozHidden !== "undefined") { 
      hidden = "mozHidden"; 
      visibilityChange = "mozvisibilitychange"; 
      state = "mozVisibilityState"; 
     } else if (typeof document.msHidden !== "undefined") { 
      hidden = "msHidden"; 
      visibilityChange = "msvisibilitychange"; 
      state = "msVisibilityState"; 
     } else if (typeof document.webkitHidden !== "undefined") { 
      hidden = "webkitHidden"; 
      visibilityChange = "webkitvisibilitychange"; 
      state = "webkitVisibilityState"; 
     } 

     // Add a listener that constantly changes the title 
     document.addEventListener(visibilityChange, function() { 

      if (localStorage.getItem("AccountName")) { 
       $("#txtGrower").val(localStorage.getItem("AccountName")); 
      } 

      if (localStorage.getItem("AccountID")) { 
       $("#hdnGrower").val(localStorage.getItem("AccountID")); 
      } 

      }, false); 

जोड़ें बच्चे पेज में निम्नलिखित (कोई पसंदीदा घटना)

function CloseChildAndLoadValuesToParent() { 

       localStorage.setItem("AccountName", 'MyAccountName'); 
       localStorage.setItem("AccountID", 'MyAccountID'); 

       window.close(); 


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