In a current html page, I have an onclick
event attached to a button, that will redirect to a new page. On that new page, I need to use document.getElementById
... to make changes on the new page. As expected after redirection, document.getElementById
... returns null maybe because it is still considering the previous page that doesn't have element with specified id.
I use :
window.location.assign(url_of_new_page);
document.getElementById("id1").innerHTML="SOMETHING";
The error here says:
cannot set property 'innerHTML' of null.
Any hint on dealing with this would be appreciated!