简体   繁体   English

Google Maps如何在不重新加载和不使用历史API的情况下更改其URL?

[英]How does google maps change its URL without reloading and without using the history API?

So if you do anything on google maps (maps.google.com) such as search or click a place etc the URL changes and the page is clearly not reloading (can tell from the inspect element/console). 因此,如果您在Google地图(maps.google.com)上执行任何操作(例如搜索或单击某个地点等),则URL会更改,并且页面显然不会重新加载(可以从inspect元素/控制台中得知)。 I thought they might be using the HTML5 history API but that doesn't seem to be the case (window.history.currentState always returns undefined regardless of how many times the URL has changed). 我以为他们可能正在使用HTML5历史记录API,但事实并非如此(无论URL更改了多少次,window.history.currentState始终返回undefined)。

So how does google do this? 那么,谷歌如何做到这一点?

Related questions from past (like 2010) also mentioned the hashtag method which they clearly don't use anymore (no hashtags anywhere in any of the URLs) 过去(例如2010年)的相关问题也提到了他们显然不再使用的hashtag方法(任何URL的任何地方都没有hashtag)

So I was wrong,they actually do seem to use the history API. 所以我错了,他们实际上确实使用了历史API。 Not sure why currentState always returned undefined but if I call window.history.state you can see the index changing and if you call back() it does what you'd expect. 不知道为什么currentState总是返回undefined,但是如果我调用window.history.state,则可以看到索引发生了变化,如果您调用back(),它可以达到预期的效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不重新加载页面的情况下将搜索参数附加到网址? - how does Google append search parameters to url without reloading page? 有没有一种方法可以更改URL而无需重新加载或更改历史记录? - Is there a method to change the URL without reloading or making changes to the history? 如何在不重新加载浏览器的情况下更改我的网址? - How to change my Url without reloading the browser? 如何在不重新加载页面的情况下更改页面 url - How to change the page url without reloading the page 如何在不重定向用户的情况下更改地址栏URL(不使用History API?) - How to change address bar URL without redirecting the user (not using History API?) 在不更改URL的情况下注入新的历史记录条目。像谷歌地图一样 - Injectng a new history entry without changing the url. Like google maps does 更改网址而不重新加载页面 - Change url without reloading the page 如何更改网址而不更改浏览器历史记录 - how to change url without changing browser history 重新加载Google Maps将API更改为复选框 - Reloading google maps places API on checkbox change 如何在不使用任何指令的情况下以角度初始化Google Maps API? - How to initialize google maps API in angular without using any directives?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM