2011-02-19 22 views
9
string dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" + app_id + "&redirect_uri=" + Server.UrlEncode(my_url) + "&scope=" + permission; 
ClientScript.RegisterClientScriptBlock(typeof(Page), "key", "window.open('"+dialog_url+"','_parent','');");

मैं पॉपअप अनुमति संवाद के लिए इस कोड का उपयोग करता हूं। जब उपयोगकर्ता पॉपअप में उपयोगकर्ता को मेरे ऐप पर रीडायरेक्ट करने की अनुमति देता है तो क्लिक करें। मुझे पॉपअप विंडो से पैरेंट विंडो में कोड भेजने की आवश्यकता है, फिर उपयोगकर्ता क्लिक करने पर पॉपअप बंद करें।पॉपअप विंडो को बंद करने और पैरेंट विंडो को रीडायरेक्ट करने के लिए

उत्तर

15

मुझे बताओ अगर यह है आप के लिए ... जनक विंडो क्या देख रहे:

<html> 
<head> 

    <script language="Javascript"> 

     function showFBWindow(){ 
      url = "allowfbchild.html" 
      newwindow=window.open(url,'name','height=200,width=150'); 
      if (window.focus) {newwindow.focus()} 
     } 

    </script> 

</head> 
<body> 

    <input type="button" OnClick="showFBWindow()" value="Open FB" /> 

</body> 
</html> 

चाइल्ड विंडो (allowfbchild.html):

<html> 
<head> 

    <script language="Javascript"> 

     function redirectToFB(){ 
      window.opener.location.href="http://wwww.facebook.com"; 
      self.close(); 
     } 

    </script> 

</head> 
<body> 

    Allow the user to view FB 
    <br/>Are you sure? 
    <input type="button" value="Ok" OnClick="redirectToFB()" /> 

</body> 
</html> 
+0

हाँ, लेकिन जब मैं पॉपअप खोलता हूं। पृष्ठ mypage.html पर रीडायरेक्ट किया गया है। मैं इस पृष्ठ पर कोड ("window.opener.location.href =" http://wwww.facebook.com ";) का उपयोग करता हूं, फिर यह कहता है .." त्रुटि: संपत्ति 'मान' का मूल्य प्राप्त करने में असमर्थ: ऑब्जेक्ट है 'window.opener.location.href' के बजाय शून्य या अपरिभाषित" – JBJumboJB

+1

आपको 'window.opener.document.location.href' – cprogcr

+0

असल में विंडो.फोकस फ़ंक्शन है, इसलिए" अगर (window.focus) {} "हमेशा होगा सच हो –

0

पैरेंट पृष्ठ जावास्क्रिप्ट लिखने में नीचे

<script language="Javascript"> 
    function popitup(url) 
    { 
     newwindow = window.open(url, "popwin", "width = 320, height = 210, resizable = no"); 
     if (window.focus) { newwindow.focus() } 
     return false; 
     popwin.moveTo(0, 0); 
     } 
</script> 

<a href="" onclick="return popitup('myapppopup.aspx');return false;">`myapppopup</a>` 

तब पॉपअप विंडो में फेसबुक के लिए एक लिंक जोड़ें

<a href="http://wwww.facebook.com" target="_blank" onclick="self.close();">facebook </a> 
संबंधित मुद्दे