Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a single page reload back into its frame?

Status
Not open for further replies.

geraldrobinson

Technical User
Joined
Sep 30, 2002
Messages
5
Location
GB
My web site uses frames. The top frame is the menu bar and the bottom frame is the content. However search engines list individual HTML pages. When you click one it loads just that HTML file, even if that page was originally intended to be loaded into a framed page!

How do I get a single HTML file to check it has been read using the correct frame page and if not then to load its-self into its correct frame page therby showing the originally intended menu bar?

Please help as its causing me hell.
 
There is a way with cookies, but if they do not accept the cookie, then your page will still not load correctly.

There is a tutorial that explains how this works without cookies. I did not write it, but I have used it quite a few times.

Here is the URL

 
geraldrobinson,

if I'm understanding you correctly, you want to make sure the bottom frame pages are in fact being displayed through the frameset, like MSDN?

simply add code in each frame page to look at the location of window.top, and if it's not equal to the path of your frameset, then load the frameset with the desired document.

you'll need to use a dynamic frameset to do this, such as:

dynFrameset.html:[tt]
<html>
<head>
<title>frameset</title>

<script language=&quot;javascript&quot;>
var sFrame = location.search.split(&quot;=&quot;)[1];
var sHTML = '<frameset cols=&quot;25%,*&quot;>' +
'<frame name=&quot;left&quot; src=&quot;nav.html&quot;>' +
'<frame name=&quot;right&quot; src=&quot;' + sFrame + '&quot;' +
'</frameset>';

document.write(sHTML);
</script>

</head>
</html>
[/tt]

one.html:[tt]
<html>
<head>
<script name=&quot;javascript&quot;>
if (window.top.location.href.indexOf(&quot;dynFrameset.html&quot;) < 0) {
window.top.location.href = &quot;dynFrameset.html?frame=one.html&quot;;
}
</script>
</head>
<body onload=&quot;&quot;>
page one
</body>
</html>
[/tt]


save these two files in the same folder, then try to open one.html by itself.

=========================================================
if (!succeed) try();
-jeff
 
Jemminger,

Thanks for your reply, you seem to have the solution I have been looking for but due to my lack of Java knowlegde I don't know how to change my current frame sets into dynamic framesets? If I list the 3 HTML files I need to get running this way could you show me the modifications required to these files?

The 3 URL's are as follows:
(frameset page)
(top menu bar page)
(bottom content page)

Other content pages exist so I assume that I would be able to use the same modifications as the first contens page in each one?
 
hi geraldrobinson,

1. you will not need to modify the top navigation frame, aside from making sure it is named .html instead of .htm, or else modify the frameset script to compensate.

2. add this code inside the <head> of every content (bottom) frame page:
[tt]
<script name=&quot;javascript&quot;>
var thisFile = window.location.href.substring
(window.location.href.replace(/\\/g,'/').lastIndexOf('/'));

if (window.top.location.href.indexOf(&quot;index.html&quot;) < 0) {
window.top.location.href = &quot;../index.html?frame=home&quot; +
thisFile;
}
</script>
[/tt]

3. here is the complete source code for the new frameset:
[tt]
<!DOCTYPE HTML PUBLIC &quot;-//SoftQuad//DTD HoTMetaL PRO
5.0::19980626::extensions to HTML 4.0//EN&quot; &quot;hmpro5.dtd&quot;>
<HTML>
<HEAD><META NAME=&quot;Copyright&quot; CONTENT=&quot;Copyright 2002 Gerald Robinson&quot;>
<TITLE>automation-information.com (UK)
</TITLE><META NAME=&quot;Description&quot;
CONTENT=&quot;automation-information.com - Supporting
the UK automation industry as the one stop site for
information on control system design and programming.&quot;><META
NAME=&quot;Keywords&quot;
CONTENT=&quot;automation,information,automation
information,control,systems,control
systems,industrial,industry,industrial automation,factory
automation,integrators,system integrators,system
integration,control systems,standards,system
design,plc,scada,human machine
interfaces,hmi,instrumentation,programmable logic
controlllers,variable speed drives,uk,allen
bradley,telemecanique,sarel,rittal,siemens,omron,schneider
electric,legrand,rockwell automation,gerald peter robinson&quot;>
</HEAD>

<script language=&quot;javascript&quot;>
var sFrame = location.search.split(&quot;=&quot;)[1];
var sDefault = &quot;home/indexmain.html&quot;;

if (!sFrame || sFrame.length == 0) sFrame = sDefault;

var sHTML = '<frameset rows=&quot;114,*&quot; FRAMESPACING=&quot;0&quot;
FRAMEBORDER=&quot;0&quot; BORDER=&quot;0&quot;>' +
'<FRAME SRC=&quot;home/indextop.html&quot; NAME=&quot;indextop&quot;
SCROLLING=&quot;NO&quot; NORESIZE=&quot;NORESIZE&quot;>' +
'<FRAME SRC=&quot;' + sFrame + '&quot; NAME=&quot;indexmain&quot;
SCROLLING=&quot;AUTO&quot;>' +
'<NOFRAMES>' +
'<BODY BGCOLOR=&quot;#FFFFFF&quot;>' +
'<P><I>automation-information.com - Supporting the UK
automation industry as' +
'the one stop site for information on control
system design and programming.' +
'automation-information.com aims to provide useful
information to engineers in' +
'the automation field, without the fuss of having
to register first or wait for' +
'lengthy HTML pages to load. The site has been
designed to be simple to use,' +
'easy to understand and fast to load. You should be
able to get to the' +
'information you want in seconds. We provide the
following services on our site:' +
'news, product Finder, system integrators,
suppliers, design information,' +
'training & Seminars, Jobs and Links. Product
Finder will help you locate' +
'manufactures for automation equipment such as
programmable logic controllers' +
'(PLC\'s), human machine interfaces (HMI\'s) and
variable speed drives (VSD).' +
'Design Information will provide you with data
sheets on electrical design and' +
'programming. system integrators and suppliers will
locate a local company' +
'within your county. jobs will help you find career
paths within the automation' +
'industry. links will help find other useful
information web sites. We also wish' +
'to work with you, to improve the site to suite
your needs.' +
'automation-information.com is currently offering
free advertising for all' +
'sections of the site. So there is no reason for
your company to be excluded!' +
'automation, information, control, systems,
industrial, industry, industrial' +
'automation, factory automation, integrators,
system integrators, system' +
'integration, control systems, standards, system
design, plc, scada, human' +
'machine interfaces, hmi, instrumentation,
programmable logic controllers,' +
'variable speed drives, uk, allen bradley,
telemecanique, sarel, rittal,' +
'siemens, omron, schneider electric, legrand,
rockwell automation, gerald peter' +
'robinson</I></P></BODY>' +
'</NOFRAMES>' +
'</FRAMESET>';

document.write(sHTML);
</script>

</HTML>
[/tt]


this should all work fine, provided the frameset resides in the root of your site, and all other documents reside in a subfolder called &quot;home&quot; off the root.

let me know if you have any problems!




===========================================================
if (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top