我遇到了一个奇怪的问题,我不知道问题是什么。下面的jQuery代码是什么,我想实现一个简化版本:iframe无法加载谷歌地图
var iframe = $('<iframe />');
iframe.prop('src', 'https://maps.google.com/maps?q=London&hl=en&sll=37.0625,-95.677068&sspn=46.677964,93.076172&t=h&hnear=London,+United+Kingdom&z=10');
iframe.appendTo($('body'));
// When the iframe loads:
iframe.load(function() {
alert(1);
});
的地图是永远不会加载,并且load()
事件永远不会触发。 Chrome浏览器报告以下错误:
Refused to display 'https://maps.google.com/maps?q=London&hl=en&sll=37.0625,-95.677068&sspn=46.677964,93.076172&t=h&hnear=London,+United+Kingdom&z=10' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
怎样一个旁路呢?
这里是jsFiddle demo。
不再明显:( – 2014-03-18 00:16:16
不工作了 – pomarc 2014-07-25 16:36:24
@pomarc不保证downvote当答案发布一年多前,这是有效的。 – BenM 2014-07-25 20:29:53