I am working in IE and FireFox compatibility. In my application we are creating dynamic iframes inside another iframe. I have to access a div inside the iframe. In IE everything is working fine. But in Firefox, I am not able to access the div. Can somebody help me out on this.

I have tried using

iframename.divname
iframename.getElementsByName("divname")
iframename.getElementById("divname")
iframename.getElementByTagName("divname") --> This was not throwing any error but the element length was 0.

I have created the iframe using the method

function getIframe(name)
{
var iframe = document.getElementById(name)
var ifDoc
if(iframe.contentDocument)
{
alert("1");
ifDoc = iframe.contentDocument
} //NS6+
else if(iframe.contentWindow)
{
alert("2");
ifDoc = iframe.contentWindow.document
} //IE
else
{
alert("3");
ifDoc = iframe.document
} //IE5
alert ("value for getIframe is "+ifDoc);
return ifDoc
}

Please help