Josh M.
Josh M.

Reputation: 27773

How to open multiple links in main browser window?

Say, for instance, you have a popup which opens from your main page. The popup contains a list of instructions. Some of these instructions have links within them. For example:

  1. [Login to your account.]
  2. Do something else...
  3. And then [click another link].

Each link click should open in the main (parent) window. So, if I click the link in #1, it loads in the main window. I login and then click the link in #3 and it opens in the main window again (where I just logged in). Here is how I'm accomplishing this now:

<a href="JavaScript:openInParent('Some.Url', false);">Login to your account</a>

<script type="text/javascript">
    function openInParent(uri, close)
    {
        window.opener.location = uri;

        if (close)
            window.close();
    }
</script>

This works fine in Chrome. Safari, Firefox, IE9 and Opera all open the first link-click fine but the second opens in a new window. Some of the browser put the entire "JavaScript:..." in the location box of the new window.

How can I make this work cross-browser?

Upvotes: 0

Views: 381

Answers (1)

Ayman Safadi
Ayman Safadi

Reputation: 11552

This worked pretty well for me: http://www.moock.org/webdesign/javascript/popupwindows/loadurlinparent.html

Upvotes: 1

Related Questions