Javascript 跨域通信
我正在开发一个iframe facebook应用程序 在某个时刻,我打开了一个facebook好友对话框,在上面我放置了一个html按钮,这样我就可以为我的应用程序添加一些特定的逻辑Javascript 跨域通信,javascript,cross-domain,Javascript,Cross Domain,我正在开发一个iframe facebook应用程序 在某个时刻,我打开了一个facebook好友对话框,在上面我放置了一个html按钮,这样我就可以为我的应用程序添加一些特定的逻辑 dialog = FB.ui({ method:'fbml.dialog', fbml: ( '<fb:request-form target="_self" action="http://devel.
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)
});
})
dialog=FB.ui({
方法:'fbml.dialog',
fbml:(
'' +
电子邮件。加入(“”)+
'' +
' '+
“
”+
'' +
'您还通过电子邮件发送'+fb.EMAILS.length+'邀请'+
“发送电子邮件”
),
尺寸:{宽:640,高:480},宽:640,高:480
});
$('.fb_dialog_iframe')。查找('iframe')。加载(函数(){
$(this).contents().find(“#电子邮件按钮”)。单击(函数(){
警报(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>).
拒绝(document.domain=)从(document.domain=)获取属性HTMLDocument.ownerDocument的权限。
有什么解决办法吗
谢谢您无法执行跨站点脚本(http://en.wikipedia.org/wiki/Cross-site_scripting)特别是对于Facebook这样的网络。唯一可能的方法是使用闪光灯或silverlight对象。感谢大家的帮助