我有一个要求,即当最终用户访问siteurl时, https://myOld_SP2010_Site.com/sites/xyz 我想将他们重定向到我的新网站,例如 https://myNEW_SPO_Site.com/sites/xyz在旧网站首页停留几秒钟后。
如何做到这一点?尽管我尝试使用下面的代码引用HERE,但它在旧站点上停留的时间并不长:
<script>
if(window.location.href == 'old_url')
{
window.location.href="new_url";
}
</script>
答案 0 :(得分:1)
window.onload = function(){
if(window.location.href == "old_ulr"){
redirectSite("new_url");
}
};
function redirectSite(url){
setTimeout(function(){window.location.href= url;}, 2000);
}