2011-01-21 102 views
2

我正在开发一个iframe facebook应用程序。跨域通信

在某些时候,我打开了一个Facebook朋友对话框,我已经把一个HTML按钮,以便我可以添加一些特定的逻辑到我的应用程序。

dialog = FB.ui({ 
       method:'fbml.dialog', 
       fbml: (
        '<fb:request-form target="_self" action="http://devel.home.net/facebook/?cmd=fb_submit_form" ' + 
         'method="post" invite="false" type="event" ' + 
         'content="Would you like to attend the '+fb.EVENT.displayName+' event? &lt;fb:req-choice url=\'http://www.facebook.com/event.php?eid='+fb.EVENT.details.fb_event.id+'\' label=\'Respond now\' /&gt;" >' + 
         emails.join('') + 
         '<input type="hidden" fb_protected="true" name="event" value="'+fb.RESPONSE.id+'"/>' + 
         '<fb:multi-friend-selector email_invite="false" import_external_friends="false" exclude_ids="'+appUsers+'"'+ 
          'condensed="true" showborder="false" bypass="cancel" actiontext="Invite your friends to join" /> '+ 

         '<br/><fb:request-form-submit import_external_friends="false"/>' + 
        '</fb:request-form>' + 

        '<div style="padding:10px">You are also sending '+fb.EMAILS.length+' invitations via email</div>' + 
        '<button id="email-button">Send Emails</button>' 
        ), 
        size: { width:640, height:480}, width:640, height:480 
       }); 


      $('.fb_dialog_iframe').find('IFRAME').load(function(){ 
       $(this).contents().find('#email-button').click(function(){ 
        alert(1) 
       }); 
      }) 

基本上,Facebook的创建对话框

所以我附上一个onload处理程序的iframe的iframe,我尝试访问按钮

在我得到的权限被拒绝错误

Permission denied for <http://devel.home.net> (document.domain=<http://home.net>) to get property HTMLDocument.ownerDocument from <https://www.facebook.com> (document.domain=<https://facebook.com>). 

有什么解决方法吗?

感谢

+2

对不起,但没有;) – 2011-01-21 17:04:09

回答

1

您不能执行跨站脚本(http://en.wikipedia.org/wiki/Cross-site_scripting)特别到网络如Facebook。

0

只有可能的方法是使用flash或silverlight对象。