SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access Child JavaScript Object

    Hi,

    I have a page (page 1), my page 1 has an IFRAME which loads another page (page 2).

    My page 2 has a JavaScript object declared on the page: var MyObject = new Object();

    I want to access this object from the parent page (page 1).

    I tried:

    var TempObj = document.getElementById("MyIFrame");

    TempObj.document.MyObject.value = "blah blah";

    But it said MyObject didn't exist.

    Can someone tell me how to access it in this manner?

    Thanks,

    Dale
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  2. #2
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try
    Code JavaScript:
    TempObj.contentWindow.MyObject.value = "blah blah";

  3. #3
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks

    Yes that seems to do the job, although I think the cross browser version is:

    var oDoc = (DestObj.contentWindow || DestObj.contentDocument);
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel


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
  •