PDA

View Full Version : IFrame challenge!!!


EdgarMilkman
08-06-2002, 01:00 PM
Hi there,

I'm strugling with an IFrame challenge. I'm designing a home page and want to link a document into an IFrame on a different page. Let me explain.

I have a main page named page1.html.
On that page I have several links to other pages.
I created a sort of template page with an IFrame. The page is called page2.html and the IFrame is named IF1. There is no initial page.
I have several pages with flat contents called page3.html, page4.html and so on.

What I want to establish is that depending on the link I click on on page1.html, page2.html (template with IFrame) gets loaded and the IFrame gets filled with page3.html or page4.html.

I looked at the target tags but that won't work. I even looked in to several javscripts, but I can't find an answer.

Is there anybody who has a hint how to do this, or can't it be done?

sjc_unique
08-06-2002, 03:28 PM
If i understand u correctly, u basically want a normal webpage to have an Iframe in it that can be filled with other pages/information/graphics.

If that is so i have tried to find an answer to this for a while.....with no joy....it would be a great idea to be able to do this.

If anyone can help.....it will be a great help!!!

sorry i couldnt solve the problem myself.

SJC

Vladdy
08-06-2002, 03:57 PM
My approach would be (I have not tested it as I do not do frames :D )......

make links as follows:

<a href="page2.html?frame=page3.html">page3 in page 2</a>
<a href="page2.html?frame=page4.html">page4 in page 2</a>

in page 2 have a code that would extract IFrame target from document.URL and use it to initialize IFrame.

EdgarMilkman
08-07-2002, 12:17 PM
As far as I know now this can't be done without using a server-side script. The following url explains.

HTMLForums (http://www.htmlforums.com/showthread.php?s=&threadid=14790)

beetle
08-07-2002, 03:28 PM
Vladdy is right. Use what he's got a go a bit further...(this goes into page2.html){...HTML...}
<script>
var qString = top.location.search.substring(1);
var temp = qString.split(/[=]/);
var nUrl = temp[1];
function initIframe()
{
top.frames['IF1'].location.href=nUrl;
}
</script>
</head>
<body onload="initIframe();">
{...HTML...}

EdgarMilkman
08-08-2002, 08:42 AM
Many thanks Vladdy an Beetle.

I tried it yesterday evening and it works perfectly.

beetle
08-08-2002, 03:34 PM
Good. Now the more important question...do you understand it? :D

EdgarMilkman
08-11-2002, 09:59 AM
I thought I did, but after adding a clock written in JavaScript the iframe script doesn't work anymore?

My code looks now like this;

<script language="JavaScript" src="../javascript/clock.js"></script>
<script>
var qString = top.location.search.substring(1);
var temp = qString.split(/[=]/);
var nUrl = temp[1];
function initIframe()
{
top.frames['IF1'].location.href=nUrl;
}
</script>

beetle
08-12-2002, 06:01 AM
I'd have to see the JS for the clock script. There's obviously something causing a conflict. the first couple of place to look are usually onLoad events and variables names...

EdgarMilkman
08-12-2002, 02:51 PM
Ok. Here is the script. I read something about some incompatibility with NS6. Maybe that's the problem.