[英]Redirection doesn't works
I have test.html page, when it is loaded, I am redirecting it to another page: 我有test.html页面,加载后将其重定向到另一个页面:
window.location.href = 'https://some.page'
But then when I am trying to get html source of new page: 但是,当我尝试获取新页面的html源时:
console.log("innerHTML " + window.document.documentElement.innerHTML);
I am still getting html source of old test.html page. 我仍在获取旧的test.html页面的html源。 How can I access to new loaded page http://some.page ?
如何访问新加载的页面http://some.page ?
You should try: 你应该试试:
document.addEventListener("DOMContentLoaded", function(event){
window.open("https://some.page")
});
This function first loads the document and then executes what is inside. 此函数首先加载文档,然后执行其中的内容。
Try this: 尝试这个:
window.onload = function() {
console.log("innerHTML : " + window.document.documentElement.innerHTML);
}
window.location.href = 'https://some.page';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.