www.webdeveloper.com
Results 1 to 8 of 8

Thread: Need Urgent help in IFrames

  1. #1
    Join Date
    Jun 2010
    Location
    India
    Posts
    4

    Need Urgent help in IFrames

    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

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    iframename.document.getElementById("divname")
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Jun 2010
    Location
    India
    Posts
    4
    I have tried that also. I was getting JavaScript error saying iframename.document is not defined. I guess the getIframe() is taking care of that.

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Give the iframe a name
    Code:
    <iframe src="index.htm" name="foo"></iframe>
    then:
    Code:
    foo.document.getElementById("divname")
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Jun 2007
    Posts
    667
    Are you certain that the new iframe's document has loaded at the point that you're trying to access it?
    Y_U U_G_A_E_U_ B_S_A_D_

  6. #6
    Join Date
    Jun 2010
    Location
    India
    Posts
    4
    I have already created the frame and named it.

    <iframe id="location" name="location" src="javascriptarent.buildLocationTable()" scrolling=yes width=600 height=400 marginwidth=0 marginheight=0></iframe>

    But I am creating sub frames within the same frame and then I am trying to access the divname which is not working.

  7. #7
    Join Date
    Jun 2010
    Location
    India
    Posts
    4
    Quote Originally Posted by Sterling Isfine View Post
    Are you certain that the new iframe's document has loaded at the point that you're trying to access it?
    yes. I am checking that before accessing the divname.

  8. #8
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    "location" is a keyword, try with a different name.
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles