我遇到了一個奇怪的問題,我不知道問題是什麼。下面的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