[英]Intercept the transition event back
I am writing a site on asp net core and all pages in it are presented in the form of partialview. 我正在ASP网络核心上编写一个站点,并且其中的所有页面都以partialview的形式呈现。 Thus, I achieve a spa model without using angular and other frameworks.
因此,我无需使用角度框架和其他框架即可实现spa模型。 When switching partialview, I can change the url of the page using
切换partialview时,我可以使用来更改页面的URL
window.history.pushState ("object or string", "Title", "/ new url");
But when I switch back in the browser, my url just changes to the previous one, and partialview does not change. 但是,当我切换回浏览器时,我的URL只是更改为上一个,而partialview却没有变化。 I want to intercept this transition and call the desired presentation.
我想拦截此过渡并调用所需的演示文稿。 Is it possible?
可能吗?
I think window.onpopstate
or window.onhashchange
would be useful. 我认为
window.onpopstate
或window.onhashchange
会很有用。 In your case you're creating history by pushstate which fires the former one when this entry has changed or replaced. 在您的情况下,您将通过pushstate创建历史记录,当该条目被更改或替换时,将触发前一个历史记录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.