Click to See Complete Forum and Search --> : Targeting Frame Content
Cutter John
01-10-2003, 04:02 PM
I'm trying to create a link that opens a frameset page, but opens a specified page (other than what normally appears) within the main content frame.
For example: Let's say my index page is a frameset containing 2 frames, one is the Leftbar frame and the other is the MainContent frame. The MainContent frame is set to load a welcome page when linking normally. However, I want to create a link from another site to open the index page, but load, let's say, a What'sNew page within the MainContent frame.
How do I accomplish this in an html link?
Thanks.
Take a look at this thread:
http://forums.webdeveloper.com/showthread.php?s=&threadid=2111
Or, here's a JavaScript method.
First change your index page to the code below. What it will do is set homepage.html to be the page *** ou didn't specify a different page, or if you did (by specifing a ? in the a href [see below]) I have commented the code so you can see what is happening.
<script type="text/javascript">
<!--Hide
linkURL = "homepage.html" //set the default URL to load if there was no referrer
if (top.location.href) { //to be compatible with IE use top.location.href instead of parent.document.URL
pageURL = top.location.href //set the top.location.href to parentURL
if (pageURL.indexOf('?') != -1) { //Check for the referring page
linkURL = pageURL.substring (pageURL.indexOf('?')+1, pageURL.length) //parse the top.location.href to remove everything before the ?
}
}
document.write('<FRAMESET ROWS="67,*,35" Border=0>')
document.write('<FRAME SCROLLING=NO NORESIZE SRC="top.html" NAME="top">')
document.write('<FRAME NORESIZE SRC="' + linkURL + '" NAME="homepage">') //this is the frame that the content is loaded into
document.write('<FRAME SCROLLING=NO NORESIZE SRC="address.html" NAME="address">')
document.write('<\/FRAMESET>')
//End hide-->
</script>
Then, use this link to force your page into the content cell, where yourpage.html is the page you want in the frameset.
<a href="index.html?yourpage.html">Force page into frameset</a>
Pyro, that works, but what would you do when sometimes want the topframe and sometime the bottomframe to change?
Originally posted by swon
Pyro, that works, but what would you do when sometimes want the topframe and sometime the bottomframe to change? When I wrote that code, I didn't need to be able to do that. If there sever has PHP enabled, yours is the better way. :D
Pyro, by the way:
I saw that your preferred prog language is PHP like mine too, my question to you (cause here's no phpforum):
Do you have any sources for creating pdf files with php, I've found a few, but when I try to create a pdf files from a phpfile which contains tables, I can't get it to work. Any ideas?
Yup, my preferred scripting language is PHP. Gotta love PHP. :D
I've not had the need to make a pdf file in PHP, yet, so I don't know a whole lot about that aspect of it. Sorry, wish I could help you. Maybe I can... Head over to http://www.phpbuilder.com -- there is an excellent PHP forums over there. (over 35,000 registerd users!) That's where I hang out for my PHP needs. :)
Stefan
01-11-2003, 06:25 PM
Originally posted by pyro
First change your index page to the code below. What it will do is set homepage.html to be the page *** ou didn't specify a different page, or if you did
It will also prevent at least 10-15% of the visitors from ever reaching the site.
Where is the backup for when JS is not available?
This is definitly something that should be done serverside instead of relying on clientside scripting.
If serverside languages are NOT available I would recomend providing an entire frameset for each specific link to mimimize the risk of the entire site breaking compleatly.
Or, go ahead a specify a <noscript> frameset.
Stefan
01-11-2003, 06:46 PM
Originally posted by pyro
Or, go ahead a specify a <noscript> frameset.
It's a lot better as it won't leave an empty white page for a visitor, but it only partially works in this case.
The URL refering will still fail without JS, so the visitor will get to the wrong page.
To do this reliably you need
a) serverside scripting
or
b) manually provide a frameset for each single page in frame name="main".