我遇到了一个奇怪的问题,我不知道问题是什么。以下 jQuery 代码是我想要实现的简化版本:
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 演示。