In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to get pushState events, the article is very detailed, has a certain reference value, interested friends must read it!
History.pushState and history.replaceState can change the URL without refreshing the current page, but it is not possible to get the content of the new page obtained through AJAX.
Pushstate event message
Although various HTML5 documents say that the _ window.onpopstate event can intercept messages from pushState, in the actual test, onpopstate has no effect at all and cannot intercept messages from pushState.
After some Google, I found the code to get the pushState event correctly.
Get the code for the pushState event correctly
/ / Addthis:
Var_wr=function (type) {
Varorig=history [type]
Returnfunction () {
Varrv=orig.apply (this,arguments)
Vare=newEvent (type)
E.arguments=arguments
Window.dispatchEvent (e)
Returnrv
}
}
History.pushState=_wr ('pushState')
History.replaceState=_wr ('replaceState')
/ / Useitlikethis:
Window.addEventListener ('pushState',function (e) {
Console.warn ('THEYDIDITA GAING')
})
Window.addEventListener ('replaceState',function (e) {
Console.warn ('THEYDIDITA GAING')
})
This code rewrites the original function in history and then activates an event itself
This can solve the problem that pushState cannot activate events.
Also remember that it is best to execute this code before the document is loaded.
The above is all the content of the article "how to get pushState events". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.