Results 1 to 5 of 5

Thread: Changing the innerHTML of a div inside an iframe.

  1. #1
    Join Date
    Nov 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Changing the innerHTML of a div inside an iframe.

    how to do it by javascript?
    i tried:
    window.frames[framename].document.getElementByID(divname).innerHTML

    is something wrong with that?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's getElementById(), case sensitive. The page inside the frame must be on the same domain for security reasons. innerHTML is non-standard and standard DOM methods should be used instead.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Also, the document within the iframe is referred to differently by various browsers. Since this only works on pages on the same domain, one would assume that if you have editing privileges for the top document, you have them for the one in the iframe. Put your script on it. You can then call the script from the top page in a much more consistent cross browser fashion than you can perform document actions from the top page upon the en-framed page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Nov 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    uhh.. sori but i just cant understand what your saying because im too noob in javascript. but, is there a way to access a div inside an iframe ?

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by lordjeremiahs View Post
    uhh.. sori but i just cant understand what your saying because im too noob in javascript. but, is there a way to access a div inside an iframe ?
    That being the case, do you at least understand what being on the same domain means? If not, you need to. If you do, but the pages are not, it cannot be done using javascript alone and is probably beyond what is permitted in these forums, unless you own both domains, in which case something may be able to be worked out.

    A domain, by the way is, for example:

    www.somename.com

    The pages have to be on the same domain.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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