不安全的 JavaScript 尝试使用谷歌地图访问框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9476941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unsafe JavaScript attempt to access frame with google maps
提问by Rafael Sedrakyan
Google chrome gives me this message when I am using google maps frame on my contacts page:
当我在我的联系人页面上使用谷歌地图框架时,谷歌浏览器给了我这条消息:
Unsafe JavaScript attempt to access frame with URL http://localhost/igames/index.php?page=contact_us&&lang=rusfrom frame with URL http://maps.google.com/?ie=UTF8&ll=44.590467,-105.820312&spn=10.747987,23.269043&t=m&z=6&vpsrc=6&output=embed. Domains, protocols and ports must match.
不安全的 JavaScript 尝试从 URL http://maps.google.com/?ie=UTF8&ll=44.590467,-105.820312&spn= 的框架访问 URL http://localhost/igames/index.php?page=contact_us&&&lang=rus的框架 10.747987,23.269043&t=m&z=6&vpsrc=6&output=embed。域、协议和端口必须匹配。
Is there any way to fix it?
有什么办法可以解决吗?
回答by PowerKiKi
For reference, it would seems to be a bug in Google Chrome: http://code.google.com/p/chromium/issues/detail?id=43173
作为参考,它似乎是谷歌浏览器中的一个错误:http: //code.google.com/p/chromium/issues/detail?id=43173
Ben Lee's workaround seems to be the only workaround as long as it doesn't get fixed in Google Chrome.
Ben Lee 的解决方法似乎是唯一的解决方法,只要它没有在 Google Chrome 中得到修复。
回答by lafeber
It's a bug in Chrome. To get rid of it, use the following code:
这是 Chrome 中的一个错误。要摆脱它,请使用以下代码:
<div id="map_canvas"></div>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var centerNL = new google.maps.LatLng(52.093008,5.12);
var myOptions = {
zoom: 11,
center: centerNL,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN,
position: google.maps.ControlPosition.TOP_RIGHT
}
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
</script>
Replace LatLng and zoom with your own values.
用您自己的值替换 LatLng 和缩放。
回答by neu-rah
I had the same issue when using chrome on a page with a google map iframe (untouched and pasted from the google maps site).
在带有谷歌地图 iframe(未触及并从谷歌地图网站粘贴)的页面上使用 chrome 时,我遇到了同样的问题。
for me this problem was solved just by navigating my site with the www. in front of it, in spite of the url not being mencioned in the iframe or in the registration of the place.
对我来说,这个问题只是通过使用 www 浏览我的网站来解决的。在它前面,尽管 url 没有在 iframe 中或在该地点的注册中被提及。
this looks like a google maps bug.
这看起来像一个谷歌地图错误。
till they solve i will redirect my trafic to the www. version (thats is the exact same).
在他们解决之前,我会将我的流量重定向到 www。版本(这是完全相同的)。
回答by kranthi kumar pulivarhty
If you use an iframe
then you get this error. Try to change your code to use an object
tag as follows:
如果您使用 aniframe
那么您会收到此错误。尝试更改您的代码以使用object
如下标记:
<object width="560" height="340">
<param name="movie"
value="http://www.youtube.com/v/JTttSMPz3Y4&hl=en_GB&fs=1&"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/JTttSMPz3Y4&hl=en_GB&fs=1&"
type="application/x-shockwave-flash"
allowscriptaccess="always"
allowfullscreen="true"
width="560"
height="340"></embed>
</object>