SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Screwy problem with popup and frames...

    Attn: All JS junkies (anyone smarter than me...yes that includes you),

    I have a (home) page that consists of 4 individual frames. The main frame of the page is named 'body', therefore all of the links in the other frames have to target 'body'. Simple stuff.

    Since I have added the script below, the links in the other frames 'can't find' the 'body'...all of the links are opening in new browser windows...not the desired effect. Can anyone let me know what's going on here??

    The popup is launched from the initial 'body' page, therefore when you click the link in the popup it launches the specified URL in the 'body' frame. It is done with the cookie detection so it only shows once per session. It seems as though the cookie function is somehow connected, but I don't see how one can affect the other!?!

    Help, please! Thanks, -TC
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    function GetCookie(name) {
    var arg=name+"=";
    var alen=arg.length;
    var clen=document.cookie.length;
    var i=0;
    while (i<clen) {
    var j=i+alen;
    if (document.cookie.substring(i,j)==arg)
    return "here";
    i=document.cookie.indexOf(" ",i)+1;
    if (i==0) break;
    }
    return null;
    }
    var visit=GetCookie("COOKIE1");
    if (visit==null){
    var expire=new Date();
    window.name = "thiswin";
    newwin=open("LTG_cruise_popup.html", "dispwin", 
    "width=500,height=345,scrollbars=no,menubar=no");
    expire=new Date(expire.getTime()+7776000000);
    document.cookie="COOKIE1=here; expires="+expire;
    }
    // -->
    </SCRIPT>
    Also, If I try and launch it from any other frame, it replaces that frames content with the URL from the popup. I tried telling it 'target="body"', but it wouldn't work.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Frames are essentially window objects; a frame's name is therefore reflected in its window[self/top/parent/this].name property.

    ........
    ........
    window.name = "thiswin";

    Just renamed your 'body' frame. So much for targeting it.

    Probably best to use something other than 'body', as it's a key DOM identifier. 'main' seems popular....
    ::: certified wild guess :::

  3. #3
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks

    Thanks for the quick reply, adios.
    So, are you saying that since it's renamed I can no longer target 'body' or can I just re-rename it 'body' (window.name = "body";) and it will work?

    Or does it need to stay 'thiswin' to operate properly?

    Because I would have to change a 'heckuva-lotta' target attributes (probably close to 300) throughout the site.

    Sorry for being 'simple'.

    Thanks,
    -TC

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I might be missing something here, but...why does that script rename the 'launch' window at all? Presumably - hard to tell without seeing the documentation, if any - it's to allow the pop-up page to target the opener window. Since you're using a frameset, the opener 'window' ('body' frame) already is named, and can be left alone. Just eliminate that line - the one I cited above. If 'LTG_cruise_popup.html' contains any links targeted to 'thiswin', just change them to TARGET="body".

    Think of it this way: a link without a target will load its HREF in the same window; the TARGET attribute allows you to specify another window/frame (by name) as the location of the new page. HTML handles all this intrinsically.
    ::: certified wild guess :::

  5. #5
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hmmm...

    Good question - why didn't I think of that?
    Actually I think it was suppose to go hand-in-hand with another script in the popup that calls the target 'thiswin', but I wound up using
    Code:
    <script>
    <!--
    function remote2(url){
    window.opener.location=url
    window.close();
    }
    //-->
    </script>
     
    <a href="javascript:remote2('http://mylinkhere')">Go There!</a>
    to link to the URL, so I guess it was not necessary.

    Thanks for initially drawing my attention to the problem area though. I did get it working.

    Thanks,
    -TC


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •