473,396 Members | 1,760 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,396 software developers and data experts.

View with or without frames - giving users the choice

Hi All!

I have a frameset document and I want each mainFrame document to have
the following ability:
- be viewed by itself (i.e. without frames if within frameset).
- be viewed within frame (i.e. put back in the frameset if not within
frameset).

I have written the following so far:

<script type="text/javascript" language="JavaScript">
<!--
function withFrames()
{
if (parent.frames.length == 0) {
parent.location.href='/RobertMarkBram/index.htm';
// parent.mainFrame.location.href=document.location.h ref;
}
} // end withFrames function
function withoutFrames()
{
if (parent.frames.length != 0) {
parent.location.href=document.location.href;
}
} // end withFrames function

document.write("<p onClick='withFrames();'>View with frames.</p>");
document.write("<p onClick='withoutFrames();'>View without
frames.</p>");

-->
</script>

My problem is to get the 'target' page loaded back into mainFrame..

You can see my attempt here:
http://phd.netcomp.monash.edu.au/Rob...osal/index.htm

Any help would be most appreciated!

Rob
:)
Jul 23 '05 #1
2 1796
In article <fa**************************@posting.google.com >,
re********@optusnet.com.au enlightened us with...
Hi All!

I have a frameset document and I want each mainFrame document to have
the following ability:
- be viewed by itself (i.e. without frames if within frameset).
- be viewed within frame (i.e. put back in the frameset if not within
frameset).

I have written the following so far:


You need a dynamic frameset.
This is best done server-side, but as long as you're already using
javascript...
This is the one I wrote that has two frames. Watch for word-wrap and put
your doc names in the sources and change the frame names and attributes
as desired. You pass the url to the frameset.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
"http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>Test Javascript Dynamic Frameset</title>
<script language="javascript" type="text/javascript">
function loadMainFrame()
{
/* See if the url has a doc to load and load it if present.
The page to load is expected to be in the param "url" as in
http://www.servername.com/testFrames...testFrame3.htm.
If the param is absent, nothing is changed, which will keep the
default page in the mainFrame.
*/

var searchString = window.location.search.substring(1);
if (searchString == null || searchString.length == 0) return; // if
no params specified, do nothing

var pairs = searchString.split('&'); // allows more params than just
the url for extensibility
if (pairs == null) return; // if no params specified, do nothing

// pairs has the pairs of values, like url=whatever.htm, param2
=value2, param3=value3
// we split that up by the = sign into an associative array (hash)
for easy lookup
var tmp;
var paramArray = new Array();
for (var i=0; i<pairs.length; i++)
{
tmp = pairs[i].split("=");
paramArray[tmp[0]] = tmp[1];
}

// paramArray should now have values like paramArray["url"]
=whatever.htm, paramArray["param2"]=value2
if (!paramArray["url"]) return; // if no url specified, do nothing
else window.frames["mainFrame"].location.href=paramArray["url"];
return;
}
</script>
</head>

<frameset cols="110,*" onLoad="loadMainFrame()">
<frame src="testFrame1.htm" name="leftFrame">
<frame src="testFrame2.htm" name="mainFrame">
</frameset>
</html>

--
--
~kaeli~
Suicide is the most sincere form of self-criticism.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Hi Kaeli,
I have a frameset document and I want each mainFrame document to have
the following ability:
- be viewed by itself (i.e. without frames if within frameset).
- be viewed within frame (i.e. put back in the frameset if not within
frameset).

I have written the following so far:


You need a dynamic frameset.
This is best done server-side, but as long as you're already using
javascript...


Thank you very much for your suggestion. I started looking for a
solution using ASP serverside singe I agree with your suggestion.. but
in the end I have decided to avoid frames altogether and use
serverside templates. But thank you again for your time - it is much
appreciated!

Rob
:)
Jul 23 '05 #3

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

Similar topics

2
by: Don Schneider | last post by:
I tried to setup a frameset which consists of 4 different subframes. Each of these subframes should fetch a different web page from the internet and display it completely (!). BUT: the vertical...
40
by: JohnnyCJohnny | last post by:
Is it pretty safe to say that almost all web surfers now use browsers that are Frames compatible? What are most people using these days? IE? Thanks
31
by: wallster | last post by:
please keep the flaming to a minimum (a bucket of water is next to me) but I have a question someone here might be able to explain in basic terms for a dunce like me. I helped a friend put...
2
by: Robert Stearns | last post by:
Can I construct a restricted view and grant select access on it to a user without granting select access to the underlying tables and views? This seems to be an easy way to restrict a user to just...
1
by: SteveComplex | last post by:
I'm currently working on a project developing a web application that makes heavy use of 3rd-party controls, popup windows and frames ( not my design I hasten to add ). Some of the pages make use...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
7
by: rjames.clarke | last post by:
Back when frames were in vogue, we would set up the navigation or menu bar to change the content of the main frame. This had the advantage of not requiring the whole page to reload. Just the...
12
by: MartinRinehart | last post by:
They just don't get no respect. "In the early days of JavaScript, multiframe and multiwindow web applications were fairly common. Now, web design has turned strongly against the use of frames...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.