LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   window.location.href (https://www.linuxquestions.org/questions/programming-9/window-location-href-4175421047/)

ShaqDiesel 08-08-2012 12:34 PM

window.location.href
 
Hi, I am doing window.location.href=<url> followed by an alert("hello") and then a document.getElementsByTagName('a'). It navigates to the url, but no alert box comes up and I am unable to get the elements on the new page. What is going on? Thanks.

NevemTeve 08-08-2012 12:46 PM

The same as in the previous topic: the new page replaces the old one (and replacing includes deleting).
Plus, it would be a security hole to be able to access another website's elements. (Just think of net-banking: you don't want your private data stolen.)

ShaqDiesel 08-08-2012 12:49 PM

so how do i perform operations on the new page?

NevemTeve 08-08-2012 01:04 PM

By adding javascript into the new page, obviously. If it someone else's page, then it is a good thing you cannot manipulate it from your code. (Read my prev post.)


All times are GMT -5. The time now is 10:36 AM.