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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading a page with one frame from a page with two frames

Status
Not open for further replies.

Empeethree

IS-IT--Management
Mar 27, 2000
192
US
Hey all,
I have been racking my brain trying to figure this out. I have a website that has an index page with one iframe in it. Then a couple pages have two iframes ( a menu frame and content frame). I am trying to get it so when i click on a link back to a page with one frame from the two frame page it goes back to the index page and puts the correct on content in its iframe. I found something on here that works but I have to double click it. I only want them to have to single click.

here is an example of what i tried
<area href=&quot;index.htm&quot; target=&quot;_top&quot; onClick=&quot;javascript:parent.main.location='project/project.htm' shape=&quot;rect&quot; coords=&quot;460, 5, 523, 22&quot;>
<area href=&quot;index.htm&quot; target=&quot;_top&quot; onClick=&quot;javascript:parent.main.location='services.htm' shape=&quot;rect&quot; coords=&quot;526, 7, 583, 21&quot;>
<area target=&quot;_top&quot; href=&quot;index-resume.htm&quot; shape=&quot;rect&quot; coords=&quot;589, 7, 652, 21&quot;>

here is the actual site in question
I know just enough about javascript to get by.. so I cant figure this one out..


thanks in advance
rob
--------------------------------------
Trying is the first step to failure
Homer Simpson
--------------------------------------
 
The simplest way is to put the following in between the head tags of the pages you only want to show in the one frame page.
<script>
<!--
if (top==self)
self.location.href=&quot;index.htm&quot;;
-->
</script>
hope this helps
Ian Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
By the way

<area href=&quot;index.htm&quot; target=&quot;_top&quot; etc

should really be in the following format

<a href=&quot;index.htm&quot; target=&quot;_top&quot;>Click Me</a>

that may be why it doesn't work and there are a lot of javascript errors on the site.

Regards
Ian Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
they are hotspot's so the area href is correct, I think. The script you posted is nice but doesnt do what I am looking for. that script will rediect non frame pages to the main frame page.. I need to go from a main page with two frames to a main page with one frame and fill the frame with the correct content page..

thanks
rob --------------------------------------
Trying is the first step to failure
Homer Simpson
--------------------------------------
 
Create your single page frame as follows
<!-- index.html -->
<html>
<head>
<title>Your site</title>
</head>

<script>
ref = location.href;


pageRE = /(\?|\&)page=(\w|,)*/;
pageStr = ref.match(pageRE);

// Set the default page to be shown in the frame when the frameset is
// loaded without parameters
// change welcome to page you would normally
// load but leave out the htm or html part

page = &quot;welcome&quot;;

if(pageStr != null) {
// remove the (? or &)page= part of the string
page = pageStr[0].substring(6, pageStr[0].length);

// change all comma's back to slashes
page.replace(&quot;/,/&quot;, &quot;/\//&quot;);
}

document.write(&quot;<frameset border='0'>&quot;);
document.write(&quot;<FRAME NAME='Mainframe' SRC='&quot; +
page + &quot;.html' SCROLLING=AUTO NORESIZE FRAMEBORDER='0'>&quot;);

document.write(&quot;</FRAMESET><noframes>Put your no-frames content here (description + keywords), some prehistoric search enignes will only read this!</noframes>&quot;);

</script>
</html>


Then in every page you want to load in the single frame page change the body tag as follows

<body OnLoad=&quot;if(parent.frames.length==0)top.location='index.html?page=page2';&quot;>

you will need to change page=page2 to whatever the pagename is agian without the html part
Hope this helps
Regards
Ian Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top