SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Access Child JavaScript Object
-
Sep 30, 2007, 22:19 #1
- 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,
DaleIf you aren't living life on the edge
- you're taking up too much space
Creative Dreaming Ltd / Ask The Local / Amanzi Travel
-
Oct 1, 2007, 04:12 #2
- 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";
-
Oct 1, 2007, 15:58 #3
- 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