Frames Loading

I am looking for a script or technique to ensure a frameset is loaded around a particular page whenever it is loaded. I have a site with frames and no frames in various sections. If a visitor searches from the top level of the site to a page designed to be nested in a frameset how do I ensure the page is alway in the desired frameset and not just the page on it's own?
legault40Asked:
Who is Participating?
 
calumscottConnect With a Mentor Commented:
Or of course combine the two to check that the browser is java enabled and then kick of the if (window == top) script.

You will of course need to put this code at the top of all of your pages that must be in framesets.

Let me know how you go.

C.
0
 
compmaniaCommented:
You would have to make an HTML file with the frameset content of the other pages but your problem would be that the frames would stick.
0
 
calumscottCommented:
Your answer lies with the target= tag.

target="_self" allows the link to open in the same frame.
target="_top" opens the link in the whole window.
target="_blank" opens the link in a new window.
target="_parent" opens the link in the parent frame. (If you have a frameset within a frame, it uses the frame currently containing the frameset).

If you are going from non-frames to frames, don't do anything just link to your frames page.  If you are going from frames to non-frames specify target="_top".

When going from frames to more frames things get a bit tricky and you have to remember where all your frames came from.

You also have the capability to specify target="framename" and explicitly say which frame you want the page to open in.

The syntax for target is...

<a href="URL" target="target option">text</a>

Have fun!

C.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
legault40Author Commented:
Not sure ny of the above suggestions is what I am after. Perhaps I can make it a bit clearer. What I am looking for is a frames checker technique. If an attempt is made to load a page without its corresponding frameset how can I make it always loads in the appropriate frameset. Lets say someone finds a link on a search engine and tries to link to a page within a frameset. Only the single page will load on it's own. I don't want to use a refresh tag as the page will try to reload the frameset over and over.
0
 
calumscottCommented:
Ah, right.  I guess for that you will need some kind of Javascript redirection.  So if someone starts the page without it being in the frameset it automatically loads the frames page.  Unfortunately I have absolutely no idea what the code to do this is but I'll see what I can dig up for you.

But if you are designing a site from scratch there is a way to stop search engines from looking at certain files.  It is a parameter file that resides in the root of your site that search engine "spiders" always look for (and, to the best of my knowledge, respect).  Once again it'll take me a while to find out how this works.

C.
0
 
calumscottCommented:
Here's a basic redirect.  If you can figure out how to test what the current page is, that is to say has the page been loaded into "_top" or a frame then you are sorted.  My Javascript ain't that good, sorry....

<html>
<body>
<script>
if(navigator.javaEnabled()==true)
{ w=java.awt.Toolkit.getDefaultToolkit().getScreenSize().width
h=java.awt.Toolkit.getDefaultToolkit().getScreenSize().height
}
else {w=629; h=469}
properties="width="+w+",height="+h;
window.open("framespage.htm")
</script>


<script language="javascript">

setTimeout("self.close();",1000)

</script>
</body>
</html>


Maybe someone else knows how to check what the active (_top) page is???

C.
0
 
calumscottCommented:
Skip that last one its much easier....

<SCRIPT LANGUAGE="JavaScript">

if (window == top) top.location.href = "framespage.htm";

</script>


Have fun...
0
 
legault40Author Commented:
The last comment from calumscott is close however, if I put this code on all my body pages of the framed site, it will redirect me back to the top of the site with the default body home page if the page is loaded without it's frameset not the page I want to display. Definately on the right track.

I am searching the Javascript area as well for this solution.
0
 
calumscottCommented:
What you would then have to do is to have a javascript page which loads pages into frames based on parameters passed from the original page.

But that would REALLY be testing my limited knowledge of Javascript!!!!

I'm sure there must be a PAQ on that.

C.
0
 
legault40Author Commented:
Looks like a tough question to get it 100% the way I am proposing. After checking this on the other web development areas seems there are several ways to aproach this but no one has perfected it yet.

Your solution is good and will do for the time being as it address the initial problem and prevents pages from being loaded without frames. I thank you for your valliant effort to help me solve this problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.