HighDots Forums  

conditional frameset

Javascript JavaScript language (comp.lang.javascript)


Discuss conditional frameset in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dan
 
Posts: n/a

Default conditional frameset - 03-02-2005 , 02:30 PM






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.location.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.location.href + '"
name="mainFrame" target="_top">');
document.write('<frame src="adframe.htm" 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.getTime() + days*24*60*60*1000);
document.cookie = "LATadframe=1; expires=" + expdate.toGMTString();
top.location.href = document.location.href;
}

-end script tag here -



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

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


Reply With Quote
  #2  
Old   
kaeli
 
Posts: n/a

Default Re: conditional frameset - 03-03-2005 , 10:19 AM






In article <1109791857.107458.171810 (AT) l41g2000cwc (DOT) googlegroups.com>,
hontzd (AT) yahoo (DOT) com enlightened us with...
Quote:
Has anyone else done something like this before?
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.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace



Reply With Quote
  #3  
Old   
bumbleguppy
 
Posts: n/a

Default Re: conditional frameset - 03-04-2005 , 02:51 PM



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?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.