One google maps per jquery tab in IFrame map posit

2019-08-10 01:09发布

问题:

The goal is to have two independent google maps each in a jQuery Tab. This will be included in a IFrame. When bounds_changed is triggered the lat/lng and zoom should be stored in a cookie. If there is a cookie available then the map should be positioned and zoomed regarding on the data of the cookie.

It seems to work with the common browsers except an actual Internet Explorer. IE does not "refresh" the map on the second tab.

Here's the JSFiddle with the "inner" stuff: http://jsfiddle.net/metaxos/AmVtf/5/

Here's the JSFiddle with the IFrame: http://jsfiddle.net/metaxos/x6SxB/3/

<iframe width="600px" height="600px" src="http://jsfiddle.net/metaxos/AmVtf/5/embedded/result/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

回答1:

Now this was an odd one. Been playing with it and can replicate your issue in ie10, and everything seems perfectly fine.

Just stumbled across this question however: https://stackoverflow.com/a/15930571/1856970 and it seems it's a bug with ie that stops cookies being set if you have an underscore in your machine name.... Very odd.

Try testing on another machine if you have one available.

Also see this which may be relevant:

Q7: My site is not receiving cookies when it is running in an IFRAME and the parent page is from a different domain. Why?

A: Internet Explorer has restrictions on “3rd party” cookies. 3rd party cookies are cookies which are set or sent for resources from a different domain than the top-level browsing context. You can easily confirm P3P/Cookie restrictions as the root cause of such issues by temporarily changing IE’s Tools / Options / Privacy setting to “Accept All Cookies”.

In order to allow such cookies to be sent reliably, you should send a P3P header when setting the cookie.

You can use Fiddler’s “Privacy Inspector” to view and analyze any P3P Policy. To learn more about P3P and IE, see my quick P3P guide.

Changing my privacy settings as advised above allows this to work with the iFrame version.