开发者

Scroll Google Maps in iframe

开发者 https://www.devze.com 2023-01-07 22:16 出处:网络
I\'ve embedded Google Maps via an iframe in my website. I can\'t use the API at this point which is why I\'m using the iframe.

I've embedded Google Maps via an iframe in my website. I can't use the API at this point which is why I'm using the iframe.

Is there a way to scroll the iframe so that the upper part of the Google Maps page 开发者_开发技巧(search bar, etc.) are no longer visible to the user?


If the page was hosted in the same domain, you could use the scrollTop and scrollLeft dhtml properties on the iframe.document.body. However this is unlikely if you are hosting google maps from a remote server. You will be unable to modify the child frame contents via script.

Even if you could, this would always be a fragile solution. If the structure of the Google Maps changed at all, you would have to update your scrollTop/Left mechansim. Users will still be able to click in the frame and drag up to get the frame to scroll up, or even use the arrow keys.

Trying to fix the scroll position, then blocking the user from scrolling will likely be more trouble than it is worth.

ScrollTop Doc: http://msdn.microsoft.com/en-us/library/ms534618(v=VS.85).aspx

You should probably try to eliminate whatever hurdles exist to using the API.

0

精彩评论

暂无评论...
验证码 换一张
取 消