How can Window.open link change main page url

164 Views Asked by At

Have one more question. I have two pages (one main and one window.open). Window.open have a href link. How make that if someone press the link in the window.open change the main page url and go to that url?

Main page
//////////////////////////////
htp://main.page.com
(change main page url if link pressed in window.open)
/////////////////////////////

//////////////////////
window.open
a href="#" Link
/////////////////////

1

There are 1 best solutions below

0
On BEST ANSWER

In your Main page, of course have that link that will open then child (other) file:

<div class="main">
    <a href="#" onclick="window.open('another_file.php', 'window', 'height=200,width=200');">Open new window</a>
</div>

Then on that other file:

<a href="#" onclick="redirect_parent()">Redirect Parent to google.com</a>
<script type="text/javascript">
function redirect_parent() {
    window.opener.location.href = 'http://www.google.com';
    self.close();
}
</script>

Of course change that value of google.com to that other value that you desire.