Can you get information on an iframe before it's defined?

Let me explain, I'm making a tabbed site with the content in an iframe. I want the current tab (content of the iframe) to be a different colour. Since the tabs are at the top how can I know what page I'm on?

If I put an alert before <iframe> it's null or undefined or doesn't even pop up depending on the method of tracking down the iframe. If I put the alert after the <iframe> it's populated.

My code:

<script language="JavaScript">
var items = new Array();
items['a'] = '/a.php';
items['b'] = '/b.php';
items['c'] = '/c.php';

for(var item in items)

if(document.getElementById("icontent").name == items[item])
document.write("<td class='tab_current'>"+item+"</td>");
document.write("<td class='tab'>"+item+"</td>");

<iframe name="icontent" id="icontent" src="/main.php" height="300" width="100%" border=0></iframe>

Please help...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


MarqisAuthor Commented:

document.frames['icontent'] is only defined/populated after the iframe tags. I need to know what page is in the iframe before it's defined. Or on the 2nd pass or whatever.

This:>>>I need to know what page is in the iframe before it's defined.

Is not logical.  If something is undefined, then obviously it cannot have any properties because it does not exist.  If it is loaded, it is defined. Otherwise the browser could not render it.

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MarqisAuthor Commented:

>I need to know what page is in the iframe before it's

I know that it doesn't sound particularily logical, but html is interpreted and it sometimes takes several passes over the code to render a page. How can I use those two features to do what I want?

Surely somebody else out there has tabbed iframes like what I'm doing?
You can't get the value of soemthing before it is there.  It does not matter how many passes it makes.  It has not properties until it is there.  Even if there was some event that you could fire during rendering (which there isn't) you could not get any value before it is rendered.

Yes others have tabbed Iframes.  They either set the after the load is completed, or they pick it up off of the events that initiate the load.  Either way is dead simple.  You are looking for a complex way of solving a simple problem;  and you are not going to get what you want without a custom browser.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarqisAuthor Commented:
Could you give me a quick code example of both methods?
You give me a B on a low point question and then want code examples?

on the link to load the new source you do it this way:

<a href="blah.htm" target="icontent"
   onclick="document.write('td etc..')">go to blah</a>

The other way requires a variable on the target page and for the on click you set a test for it.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.