Google地图内的iframe不加载 [英] Google Maps inside iframe not loading
问题描述
var iframe = $('< iframe /> ;');
iframe.prop('src','https://maps.google.com/maps?q=London&hl=zh-TW&sll=37.0625,-95.677068&sspn=46.677964,93.076172&t= H&安培; hnear =伦敦,+美国+英国&安培; Z = 10' );
iframe.appendTo($('body'));
// iframe加载时:
iframe.load(function(){
alert(1);
});
映射从不加载, 这是一个 jsFiddle demo 。 I ran into a strange issue, and I don't know what the problem is. The following jQuery code is a simplified version of what I want to achieve: The map is never loaded, and the How does one bypass this? Here's a jsFiddle demo. Appending 这篇关于Google地图内的iframe不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! load()$ c从未触发$ c>事件。 Chrome报告了以下错误:
拒绝显示'https://maps.google.com/maps?q=London&hl=zh-CN& ;因为它将'X-Frame-Options'设置为'SAMEORIGIN',所以在一帧中sll = 37.0625,-95.677068& sspn = 46.677964,93.076172& t = h& hnear =伦敦,+ United + Kingdom& z = 10'
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()
event is never triggered. Chrome reports the following error: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'.
&output=embed
to the end of the URL fixes the problem.