跨域通信

发布于 2024-10-13 03:09:29 字数 2154 浏览 3 评论 0原文

我正在开发一个 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 为对话框创建了一个 iframe

,所以我将一个 onload 处理程序附加到 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>).

有没有任何解决方法?

谢谢

I am developing an iframe facebook app.

At some point, I open a facebook friends dialog on to which I have put a html button, so that I can add some logic specific to my app.

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? <fb:req-choice url=\'http://www.facebook.com/event.php?eid='+fb.EVENT.details.fb_event.id+'\' label=\'Respond now\' />" >' + 
                        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)
                });
            })

Basically, Facebook creates an iframe for the dialog

So I attach an onload handler to the iframe and I try to access the button

At that I get the permission denied error

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>).

Is there any workaround?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

影子是时光的心 2024-10-20 03:09:29

您无法执行跨站点脚本 (http://en.wikipedia.org/wiki/Cross-site_scripting),特别是对于 Facebook 等网络。

You cannot perform Cross-site scripting (http://en.wikipedia.org/wiki/Cross-site_scripting) particularly to a network such as Facebook.

长途伴 2024-10-20 03:09:29

唯一可能的方法是使用闪光灯或银光物体。

Only possible way is using either a flash or a silverlight object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文