#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Sewaren, NJ
    Posts
    3
    Rep Power
    0

    Question close popup and load in main window


    I have designed a site that requires a monthly popup window to advertise the latest special. As of now when you click a link in the popup window, the popup window closes and the link opens in a new window.

    I need the link to open in the MainFrame of the main window. How can this be done?

    The site is www.usapracticegear.com
  2. #2
  3. macho member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    207
    Rep Power
    16
    Forgot where i got this from but it works nicely.

    On your main site homepage add this:

    <script language="JavaScript" type="text/JavaScript">

    self.name = "yourWindowName";

    </script>

    Then on your pop-up window's links, add target="yourWindowName".

    like so:
    <a href="http://xxx.xxx.xxx/xxx.html" target="yourWindowName">Link</a>

    self.name gives the main window a name, so other windows can reference it, cool ya?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Sewaren, NJ
    Posts
    3
    Rep Power
    0

    thanks so much! but...


    That got the link to load in the original page however now that it does that, how do I get it to load in only the MainFrame of that page?
  6. #4
  7. macho member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    207
    Rep Power
    16
    this works ...

    on your mainFrame html page (NOT the main window page or frameSet) add this:

    <script language="javascript" type="text/javascript">

    var getURL = top.location.search.substring(1);

    getURL = getURL.split("=");

    if (getURL != "")
    {
    window.location.href = getURL[1];
    }
    else {
    // do nothing
    }

    </script>

    then do your pop-up <a href>'s like so:
    <a href="http://www.yoursite.com?special=pagename.html" target="mainWindowName">link</a>

    ya, its the "?" query string. "special" can be named anything you want, "pagename.html" is the motherload.

    in actual fact "www.yoursite.com?special=pagename.html" can be just "www.yoursite.com?pagename.html"

    but i thought with the word "special" there as a description it would look more cool

    if you decide it's silly, then just use below code instead without the "special=" part.

    <script language="javascript" type="text/javascript">

    var getURL = top.location.search.substring(1);

    if (getURL != "")
    {
    window.location.href = getURL[0];
    }
    else {
    // do nothing
    }

    </script>

    <a href="www.yoursite.com?pagename.html" target="mainWindowName">link</a>
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Sewaren, NJ
    Posts
    3
    Rep Power
    0

    Thumbs up It works!


    "?" didn't work though, I kept getting an error message saying the server could not be found. So, I changed the "?" to "/" and voila! - it worked.

    For anyone else reading, here's what I did: On the html page that fills the mainFrame of my index page I entered...

    <script language="javascript" type="text/javascript">

    var getURL = top.location.search.substring(1);

    if (getURL != "")
    {
    window.location.href = getURL[0];
    }
    else {
    // do nothing
    }

    </script>

    Then, on the popup window page I made the link look like so...

    <a href="www.yoursite.com/pagename.html" target="mainFrame">link</a>

    If you'd like to look at how it works go to http://www.usapracticegear.com and click one of the items in the popup window.

IMN logo majestic logo threadwatch logo seochat tools logo