473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

conditional frameset

dan
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

Jul 23 '05 #1
2 1655
In article <11**********************@l41g2000cwc.googlegroups .com>,
ho****@yahoo.com enlightened us with...

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

Jul 23 '05 #2
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?

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Hans | last post by:
Hi There, I have a page that has links with some variables and I need to open the results set in a frameset. I have tried doing this in various different ways, but still cannot get the variable...
2
by: luu duong | last post by:
I know this is probably easy but here is the details. I have an asp page that is not inside a frameset. I want to post data to another asp page that is inside a frameset. So firstpage.asp has...
1
by: JP | last post by:
Hi, How can I create a dynamic frameset whose content changes based on user inputs? Specifically, how do I toggle a frame within a frameset? How can I allow a user to "close" or "dock" a...
1
by: Ian | last post by:
Here's an interesting delema. I have two on-line manuals built with frames. Each has a unique frameset. Some of the pages have related material and are linked. Is there a way to have a page...
0
by: Charles A. Lackman | last post by:
Hello, I have a frameset nested inside another frameset: <FRAMESET border="0" frameSpacing="0" rows="150,72%" frameBorder="No"> <FRAME name="header" marginWidth="0" marginHeight="0"...
3
by: mark4asp | last post by:
According to this <http://css-discuss.incutio.com/?page=BoxModelHack> IE6 will display differently to the W3C standard. Only IE6/strict and I suppose IE 7 display correctly. IE 6 transitional and...
0
by: joeller | last post by:
On October 13, 2006 Mark Rae wrote Hi, Firstly, I have not the slightest intention of using framesets - the reason for this post is merely to ask for assistance in furthering my understanding of...
12
by: Geoff Cox | last post by:
Hello I'm having a problem loading a frameset file using an include in a php file. Nothing is displayed and when I look at the source code I see that <html> <head> <title></title>
4
by: maminx | last post by:
Hello..i have problem, hope someone can help me..i have this frameset below : <FRAMESET ROWS="55%" COLS="37%,63%"> <FRAME NAME="runningTrade" SRC="http://runningtrade.com" scrolling="no"> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.