views:

102

answers:

2

Supose I create a pop-up in home.html with something like:

<a href="somepage.html" target="_new">link</a>

How can I make a link IN somepage.html change the content of the browser
window/tab that contained the original link (the windows that has home.html)?

Can this be done by plain HTML? Or do I need JavaScript?

+1  A: 

Only way I know how is with Javascript. Use window.open to open the window. In the popup, you should be able to reference it with window.opener

Cody C
Thanks, these are basically the functions I needed :)
Hugo
+3  A: 

You need Javascript.

In somepage.html, you need a link like this:

<a href="javascript:window.opener.changeUrl('newpage.html');">
  link to newpage.html for the opening window
  </a>

and then in the home.html you need a function like so

function changeUrl(url) { document.location.href=url; }

that should do it!

larson4
Couldn't you just do "window.opener.location.href = 'newpage.html';" ?
nickf