Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
Posted this in a html forum last night, no luck yet. No harm in posting it here too ...
I've been trying to figure out how to do this for about 5 hours this evening without any success.
I wish to have a menu page with 3 links. Lets call them 'cherry', 'banana', and 'orange'. Each of these links will lead to their relevent pages, cherry.html, banana.html etc
I want to have one page set up as a template holder using an Iframe that can accept any source. I'm calling this 'holder.html'.
When I follow a link from the menu page I want it to open the holder.html page, with the particular fruit page as its source in the iframe. Just to make sure thats 100% clear, if say I click cherry.html, I want cherry.html to be loaded into holder.html. If I click banana.html I want it to load into that same holder.html.
Everything I have tried has failed! 
Here is my latest attempt using script from above :
code:
menu.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<a href = "holder.html?framename=cherry.html" target = "_top">Cherry</a>
<a href = "holder.html?framename=banana.html" target = "_top">Banada</a>
<a href = "holder.html?framename=orange.html" target = "_top">Orange</a>
</body>
</html>
holder.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>
<body onload = "init(holder.html?!?')">
<script>
function init(defaultpath)
{var locsubstr = location.search.substring(1);//find url parameter
if((locsubstr.indexOf("framename")!= -1))//if there is a new path for frame
{var frameloc = locsubstr.substring(locsubstr.indexOf("=") + 1, locsubstr.length);//find the newpath for frame
if((window.location.href.indexOf("#")!= -1))
{frameloc += window.location.href.substring(window.location.href.indexOf("#"), window.location.length);}
parent.frames[0].location.replace(frameloc);//change frame to new path }
else
{parent.frames[0].location.replace(defaultpath);}//if there isn't a new path, set frame to default }
</script>
<iframe name="leisurepage" id="leisurepage"
marginwidth="0" marginheight="0"
src="do i still need this iframe bit?!?">
</body>
</html>
cherry.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 3</title>
</head>
<body>
Cherrys blah blah blah
</body>
</html>
Well this doesn't do anything and I am quite confused as to what page should be referred to in the above, where? I reckon I've made such a mess of it , might need starting from scratch ...
Any assistance will be great.
Thanks in advance
Mike
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
the way ur doing it io think php would be a good idea
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
just have the page u want it on and use <? include"$clicked.html" ?> ; or similar
and have the ahref links to point to
?clicked="cherry"
?clicked="banana"
etc do u get me
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
Thanks mate,
But nope, Im not quite with you !
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
& it will be going on a CD
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
quote: Originally posted by Mikeboy
& it will be going on a CD
ahhh
then u cant use PHP i got no idea then. ill have to relook at the code
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
er... do u really need the menu.html bit?
|
Joff
Member
Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
|
menu.html
code: <html>
<head>
<title>menu.html</title>
</head>
<body>
<a href="cherry.html" target="leisurepage">Cherry</a>
<a href="banana.html" target="leisurepage">Banada</a>
<a href="orange.html" target="leisurepage">Orange</a>
</body>
</html>
holder.html
code:
<html>
<head>
<title>holder.html</title>
</head>
<body>
<iframe name="leisurepage" id="leisurepage" marginwidth="0" marginheight="0" src=""></iframe>
<iframe name="menu" id="menu" width="300" src="menu.html"></iframe>
</body>
</html>
cherry.html
code:
<html>
<head>
<title>cherry.html</title>
</head>
<body>
Cherrys blah blah blah
</body>
</html>
banana.html
code:
<html>
<head>
<title>banana.html</title>
</head>
<body>
Bananas blah blah blah
</body>
</html>
orange.html
code:
<html>
<head>
<title>orange.html</title>
</head>
<body>
Oranges blah blah blah
</body>
</html>
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
quote: Originally posted by Joff
menu.html
code: <html>
<head>
<title>menu.html</title>
</head>
<body>
<a href="cherry.html" target="leisurepage">Cherry</a>
<a href="banana.html" target="leisurepage">Banada</a>
<a href="orange.html" target="leisurepage">Orange</a>
</body>
</html>
how does that point to the page index.htm?
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
Thanks a lot Joff
Im trying that now but it doesn't seem to open the fruit inside the iframe. Instead it just opens it in a blank new window ...
|
Joff
Member
Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
|
There was no mention of an "index.htm" page.
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
i mean holder.html
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
Thanks for your help too Groom, t'is very appreciated
|
Joff
Member
Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
|
Mike, have you cut and paste each of the 5 snippets of code into new documents?
|
Joff
Member
Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
|
Groom - cut and paste each of the 5 snippets of code into new documents, and save with the supplied file names.
|
Joff
Member
Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
|
holder.html contains two iframes.
One displays the contents of the fruit pages when requested and is given the name/id of "leisurepage" as suggested in Mike's original code.
The other iframe contains the menu page - menu.html.
Once holder.html is loaded, the name/id "leisurepage" is reference through the DOM so you can modify any property associated with it.
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
quote: Originally posted by Mikeboy
Posted this in a html forum last night, no luck yet. No harm in posting it here too ...
I've been trying to figure out how to do this for about 5 hours this evening without any success.
I wish to have a menu page with 3 links. Lets call them 'cherry', 'banana', and 'orange'. Each of these links will lead to their relevent pages, cherry.html, banana.html etc
I want to have one page set up as a template holder using an Iframe that can accept any source. I'm calling this 'holder.html'.
When I follow a link from the menu page I want it to open the holder.html page, with the particular fruit page as its source in the iframe. Just to make sure thats 100% clear, if say I click cherry.html, I want cherry.html to be loaded into holder.html. If I click banana.html I want it to load into that same holder.html.
Everything I have tried has failed! 
Here is my latest attempt using script from above :
code:
menu.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<a href = "holder.html?framename=cherry.html" target = "_top">Cherry</a>
<a href = "holder.html?framename=banana.html" target = "_top">Banada</a>
<a href = "holder.html?framename=orange.html" target = "_top">Orange</a>
</body>
</html>
holder.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>
<body onload = "init(holder.html?!?')">
<script>
function init(defaultpath)
{var locsubstr = location.search.substring(1);//find url parameter
if((locsubstr.indexOf("framename")!= -1))//if there is a new path for frame
{var frameloc = locsubstr.substring(locsubstr.indexOf("=") + 1, locsubstr.length);//find the newpath for frame
if((window.location.href.indexOf("#")!= -1))
{frameloc += window.location.href.substring(window.location.href.indexOf("#"), window.location.length);}
parent.frames[0].location.replace(frameloc);//change frame to new path }
else
{parent.frames[0].location.replace(defaultpath);}//if there isn't a new path, set frame to default }
</script>
<iframe name="leisurepage" id="leisurepage"
marginwidth="0" marginheight="0"
src="do i still need this iframe bit?!?">
</body>
</html>
cherry.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 3</title>
</head>
<body>
Cherrys blah blah blah
</body>
</html>
Well this doesn't do anything and I am quite confused as to what page should be referred to in the above, where? I reckon I've made such a mess of it , might need starting from scratch ...
Any assistance will be great.
Thanks in advance
Mike
just another idea would this work...
code:
>holder.html</
<html>
<head>
<title>holder.html</title>
</head>
<body>
<a href="cherry.html" target="leisurepage">Cherry</a>
<a href="banana.html" target="leisurepage">Banada</a>
<a href="orange.html" target="leisurepage">Orange</a>
<a href="cherry.html" target="leisurepage">Cherry</a>
<a href="banana.html" target="leisurepage">Banada</a>
<a href="orange.html" target="leisurepage">Orange</a>
<iframe name="leisurepage" id="leisurepage" marginwidth="0" marginheight="0" src=""></iframe>
<iframe name="menu" id="menu" width="300" src="menu.html"></iframe>
<iframe name="leisurepage" id="leisurepage" marginwidth="0" marginheight="0" src=""></iframe>
<iframe name="menu" id="menu" width="300" src="menu.html"></iframe>
</body>
</html>
[Edited on 31-01-2004 by groom]
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
quote: Originally posted by Joff
Mike, have you cut and paste each of the 5 snippets of code into new documents?
Yep , .
If I run it from the holder.html I see two frames, and the right frame opens links in the left frame. Which is good !
But I want to open the link from the menu.html, and have it open the holder.html with the iframe source being whatever fruit, but in the same window.
When I click the links on the menu now they do not seem to open anything ? Seems so close !
[Edited on 31-01-2004 by Mikeboy]
|
Joff
Member
Registered: 17th Oct 00
Location: Cambridgeshire
User status: Offline
|
No, that really over complicates things and you'll end up with redundant code.
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
quote: Originally posted by Joff
holder.html contains two iframes.
One displays the contents of the fruit pages when requested and is given the name/id of "leisurepage" as suggested in Mike's original code.
The other iframe contains the menu page - menu.html.
Once holder.html is loaded, the name/id "leisurepage" is reference through the DOM so you can modify any property associated with it.
it works too
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
Mmmmmmmmm
Ok, so I need to have the links showing on the same page as where the iframe gets displayed ?
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
quote: Originally posted by Mikeboy
quote: Originally posted by Joff
Mike, have you cut and paste each of the 5 snippets of code into new documents?
Yep , .
If I run it from the holder.html I see two frames, and the right frame opens links in the left frame. Which is good !
But I want to open the link from the menu.html, and have it open the holder.html with the iframe source being whatever fruit, but in the same window.
When I click the links on the menu now they do not seem to open anything ? Seems so close !
[Edited on 31-01-2004 by Mikeboy]
surely thats not possible with html
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
Thanks Groom I'll try out urs in a sec too !
|
Mikeboy
Member
Registered: 12th Jun 02
Location: Wiltshire Drives: SXi DTi
User status: Offline
|
quote: Originally posted by groom
quote: Originally posted by Mikeboy
quote: Originally posted by Joff
Mike, have you cut and paste each of the 5 snippets of code into new documents?
Yep , .
If I run it from the holder.html I see two frames, and the right frame opens links in the left frame. Which is good !
But I want to open the link from the menu.html, and have it open the holder.html with the iframe source being whatever fruit, but in the same window.
When I click the links on the menu now they do not seem to open anything ? Seems so close !
[Edited on 31-01-2004 by Mikeboy]
surely thats not possible with html
I think thats what that script was supposed to do in the first post. But it doesn't seem to work properly either !
|
groom
Member
Registered: 19th Apr 03
Location: In front of my pc
User status: Offline
|
why do u need the links on a seperate page?...
it would be easier to have the fruit pages with the little menu at the top and just have them open in a new window from menu.html
|