当某些人从Facebook提要中打开一个共享的网址,并在一段时间后关闭打开的窗口时, 问:可以在关闭事件上将用户重定向到我的网站主页的嵌入式JS代码是什么?
我现在有了BackButton代码,即:
(function(window, location) {
history.replaceState(null, document.title, location.pathname+"#!/a");
history.pushState(null, document.title, location.pathname);
window.addEventListener("popstate", function() {
if(location.hash === "#!/a") {
history.replaceState(null, document.title, location.pathname);
setTimeout(function(){
location.replace("https://mywebsite.com");
},0);
}
}, false);
}(window, location));