Question

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?

Was it helpful?

Solution

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!

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top