Click to See Complete Forum and Search --> : Can't subscribe in one line ...


Johanvh
09-22-2003, 03:24 AM
Hi, my problem is this: I have a website with frames. 2 frames are fixed, 1 frame has different pages. The searchengines found these pages, but a visitor, only see the 1 frame, not the complete website. Is there a possibility, when the visitor clicks on a link, I load the complete page, with in 1 frame a page, depending on what the visitor has clicked.

requestcode
09-22-2003, 07:22 AM
If I understand you correctly you want to insure that the document is loaded in your frames when someone navigates to it from the search engine. Here is one way. The first script would need to be placed in each document you want to force into your frame set. Here is the code:
<html>
<head>
<title>Force Frames Test</title>
<script language="JavaScript">
if (self == top)
{
var url = self.location;
self.location = "http://www.mysite.com/frset.html?" + url;
}
</script>
</head>
<body>

</body>
</html>

Then in your frameset you would check to see if there is something attached to the URL and if there is load it into a frame. If not then it would default to what you have specified in your frameset. Here is the code:
<html>
<head>
<title>Frame Print Demo</title>
<script language="JavaScript">
function frame_saver()
{
if (self.location.search)
{
parent.frameb.location = location.search.substring(1,location.search.length);
}
}
window.onload = frame_saver;
</script>
</head>
<frameset rows="25%,*" border="1">
<frame src="looka.html" name="framea">
<frame src="lookb.html" name="frameb">
</frameset>

Johanvh
09-22-2003, 08:08 AM
Hi requestcode,

Thanks for your reply

I have made a test but it doesn't work.

I made a page test.htm. When I click on a link to open that same page I would like it opened in the framestructure.
When I click on the link in a single window (without frames) the browser displays:
'The requested URL index.htmhttp://mysite.com/test.htm was not found on this server'

What did I wrong?

pyro
09-22-2003, 08:11 AM
This might help you, as well: http://www.webdevfaqs.com/javascript.php#forceframeset

requestcode
09-22-2003, 08:39 AM
This part:
http://www.mysite.com/frset.html

Needs to be changed to your Website name and whatever your document that has the frame set is. Normally that would be index.html.

Johanvh
09-22-2003, 09:25 AM
Thanks Pyro for your reply.

I have tested the example with succes, great!
Everything works good in a single directory structure, but
with subdirectorys it goes wrong.

For example: I type the url: www.mypage.com/abc/test.htm.

The browser displays: 'http://www.mypage.com/abc/index.htm?page=abc/test.htm' not found.

Probelm: index.htm is in the root not in the /abc directory.

Can you modify the script so it works good.

Thanks

pyro
09-22-2003, 09:32 AM
The current script will work fine, if set it up correctly (though if I get time, I may make some modifications to it to make it easier to use -- such as automatically reading the current pages URL).

If you have a page called test.htm in a subdir called abc, you would put this on the test.htm page:

<script type="text/javascript">
if (top.location == self.location) {
top.location.href = "/index.htm?page=abc/test.htm";
}
</script>

Johanvh
09-22-2003, 09:39 AM
Thanks !!!

It works. The only i forgot was the '/' for my index.htm?...

Great !

pyro
09-22-2003, 10:05 AM
I went ahead and updated the script for ease of use. You can get the latest version at http://www.webdevfaqs.com/javascript.php#forceframeset