Archdeacon Posted March 14, 2011 Share Posted March 14, 2011 I have 2 pages where I need to access, via javascript, certain 'id's of each one. Can I use something like 'document("index.html").getElementById("link1)' or must I hard code the common links into a javascript function? Link to comment Share on other sites More sharing options...
ShadowMage Posted March 14, 2011 Share Posted March 14, 2011 As far as I know, there is no relationship between documents. Except if documentB is opened in a new window by documentA. If that is the case you can use the opener keyword.opener.document.getElementById("elID"); Link to comment Share on other sites More sharing options...
Archdeacon Posted March 14, 2011 Author Share Posted March 14, 2011 var x = self.opener.parent.document.getElementById("link1").href;var y = self.opener.parent.document.getElementById("link1").innerHTML;document.getElementById('upper2').href = x;document.getElementById('upper2').title = y; Just what I needed; and I have used 'self.opener.parent' to get back to 'index.html'. It all works properly now.Thanks again.<a href="page2.html" onclick="window.open('page2.html','_self');return false"</a>However, if I call the page as above (in order to open the page in the same browser tab), I end up with a null reference again. Is there a way around this? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.