Forum Moderators: open

Message Too Old, No Replies

test for empty iframe

         

timo222

9:26 pm on Jul 3, 2008 (gmt 0)

10+ Year Member



I'm making a site using iframes where the main page is index.html and the other pages are shown in ifrm_1. I am trying to make it so that the iframe src is not explicitly in the tag but passed through <a href>s with target=ifrm_1 so the same parent page can be used for the whole site. This means when index.html is loaded for the first time, the iframe is empty and needs filling.

I am trying to detect this using this function:

if (window.frames['ifrm_1'].location.href=='')
{
window.frames['ifrm_1'].location.href='home.html';
}

but it doesn't work. I've tried =='', =="" and ==undefined

also, alert(window.frames['ifrm_1'].location.href) pops up saying "about:blank" so I tried testing with =='about:blank' and I can't make that work either.

Anyone know how I could do this? Or is this just a bad idea in the first place?

Cheers
Tim

timo222

9:45 pm on Jul 3, 2008 (gmt 0)

10+ Year Member



not sure what I've done but since I posted this its started working with

if (window.frames['ifrm_1'].location.href=='about:blank')
{
window.frames['ifrm_1'].location.href='home.html';
}

stupid computer.