conditional frameset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dan

    conditional frameset

    Hello -

    I'm working on a page that will deliver a frameset under certain
    conditions and delivers a normal page under other conditions. I would
    like to avoid using a redirect so that the URL doesn't change.

    I have code that works on most browsers (Mac IE and Safari don't like
    it, but that may OK). How it works is that the Javascript writes out a
    frameset at the top of a page, before the browser gets to the body tag.
    This generates the frames and prevents the body portion of the page
    from rendering.

    The code checks to see that there isn't a "turn off frames" cookie and
    that the page isn't already in a frame. If so, it writes the frameset
    tags, including a frame src pointing to itself. IE doesn't seem to like
    this, so there's a redundant line of code that loads the page into that
    frame again.

    Below the javascript code is the rest of a standard HTML body. So, if
    the framesets aren't created, and the unframed page appears normally.

    I've ommitted standard cookie-grabbing code for the sake of brevity.
    The cookie value is stored in the killFrame var.

    Has anyone else done something like this before? This feels like a bit
    of a hack, but it may be the best way (as long as I deliver it only to
    browsers that can pull it off)..

    begin code snippet:
    _______________ _________

    -script tag here-
    // ( cookie-grabbing code goes here, puts value into killFrame )

    var thisPage = self.document.l ocation.href;

    if ((self == top) && (killFrame != "1")) {
    document.open() ;
    document.write( '<frameset rows="*,110" frameborder="NO " border="0"
    framespacing="0 ">');
    document.write( '<frame src="' + self.document.l ocation.href + '"
    name="mainFrame " target="_top">' );
    document.write( '<frame src="adframe.ht m" name="adFrame" scrolling="NO"
    noresize target="_top"></frameset>');
    document.close( );
    //for IE
    top.frames[0].location.href = thisPage;
    }


    // removes frame and drops cookie when user clicks "close frame button"
    function closeFrame() {
    days = .5;
    var expdate = new Date();
    expdate.setTime (expdate.getTim e() + days*24*60*60*1 000);
    document.cookie = "LATadframe =1; expires=" + expdate.toGMTSt ring();
    top.location.hr ef = document.locati on.href;
    }

    -end script tag here -



    </HEAD>
    <BODY>
    body of page still goes here.

    </body>
    </html>
    ---------------
    end code

  • kaeli

    #2
    Re: conditional frameset

    In article <1109791857.107 458.171810@l41g 2000cwc.googleg roups.com>,
    hontzd@yahoo.co m enlightened us with...[color=blue]
    >
    > Has anyone else done something like this before?[/color]

    Conditional frames? No redirects?
    Yup.
    Didn't use client-side code, though. Or cookies. Servlets are my friend for
    stuff like this. You can do this much easier with server-side code that
    dynamically generates your html. Doesn't have to be servlets. Could be PHP,
    ASP.net, perl, JSP, or whatever. Pass in params via the URL and have the page
    generate as appropriate. Makes it easier for people to bookmark, too.

    --
    --
    ~kaeli~
    The Bible contains six admonishments to homosexuals and
    three hundred sixty-two admonishments to heterosexuals.
    That doesn't mean that God doesn't love heterosexuals. It's
    just that they need more supervision.



    Comment

    • bumbleguppy

      #3
      Re: conditional frameset

      Instead of writing the frames in the head, couldn't you use a NOSCRIPT
      tag in the body for the non-frame page and just write the frames with
      javascript in the script tag?

      Comment

      Working...