开发者

How to change a div's innerHTML after redirecting?

开发者 https://www.devze.com 2022-12-24 05:04 出处:网络
I am trying to change the innerHTML of a开发者_运维技巧 div on the page that I am loading. This is my JavaScript code:

I am trying to change the innerHTML of a开发者_运维技巧 div on the page that I am loading.

This is my JavaScript code:

function redirect(titleName){
    window.location = "pageToLoad.php";
    document.getElementById("title").innerHTML = titleName;
}

It doesn't seem to be working, please help me!!


The execution life of a script extends only for as long as the page it is running in lives.

If you want to access the DOM of one document from a script running in another, then the other page has to hang around. This means you either have to use frames or open popups.

Neither of these is a good idea. You should rethink what you are trying to achieve and find a better approach (which will probably be "Just change the title of the page you are linking to in the source of that page").

0

精彩评论

暂无评论...
验证码 换一张
取 消