The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
How to access object & values within iframe'd document
Discuss How to access object & values within iframe'd document in the JavaScript Development forum on Dev Shed. How to access object & values within iframe'd document JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 1st, 2009, 12:22 PM
|
|
Contributing User
|
|
Join Date: Mar 2008
Posts: 102
Time spent in forums: 12 h 45 m 29 sec
Reputation Power: 6
|
|
|
How to access object & values within iframe'd document
For example if I do:
Code:
<iframe id="myframe" src="http://mysite.com"></iframe>
and I want to set the value of the search field there, how do I access that field? I've already ignorantly tried:
Code:
document.getElementById('myframe').document.getElementByID('mytextArea').value
|

October 2nd, 2009, 02:08 PM
|
|
Contributing User
|
|
Join Date: Mar 2008
Posts: 102
Time spent in forums: 12 h 45 m 29 sec
Reputation Power: 6
|
|
Anyone? 
|

October 2nd, 2009, 02:52 PM
|
 |
Meatball Surgeon
|
|
Join Date: Jul 2004
Location: Elbow deep in code
|
|
|
i would actually have to dig into this is see if I'm right (its been a long time for me and frames) but i believe you should just be able to refernce like:
document.frame.form.object.value
or document.frame.getelementById("object").value;
__________________
Three gigs for the secretaries fair
Seven gigs for the system source
Nine gigs for the coders in smoky lairs
One disk to rule them all, one disk to bind them
One disk to hold the files, and in the darkness grind'em
---------------------------------------------------
It is by caffeine alone that I set my mind in motion.
It is by the beans of Java, that my thoughts acquire speed.
The hand acquire shakes; the shakes become a warning.
It is by caffeine alone that I set my mind in motion.
|

October 3rd, 2009, 08:09 AM
|
|
Contributing User
|
|
Join Date: Mar 2008
Posts: 102
Time spent in forums: 12 h 45 m 29 sec
Reputation Power: 6
|
|
|
Strictly speaking, it's an iframe, not a frame that I'm working with...don't know if that makes a difference. But either way, I'm still unclear about how to refer to elements and values within that iframe.
I mean, I might have three iframes, how does the browser know which one?
|

October 4th, 2009, 08:10 AM
|
 |
Meatball Surgeon
|
|
Join Date: Jul 2004
Location: Elbow deep in code
|
|
|
once again, its been awhile, but as i remember frames and iframes are treated the same.
|

October 5th, 2009, 07:48 AM
|
|
Contributing User
|
|
Join Date: Mar 2008
Posts: 102
Time spent in forums: 12 h 45 m 29 sec
Reputation Power: 6
|
|
|
Wasn't picking on your frames knowledge, just figured I'd be specific in case it was relevant.
I still can't do this, in any case. Isn't there some way or some tool out there that can read my document and say "sure, that DIV there is referred to as document.html.body.div[3]"? DOM Inspector does not do this within iframes.
I've tried window.frames[0-2].whatever (="URL" or "bgColor" or anything that DOM inspector claimed has in fact some value assigned). I've been trying to "alert" these values on a mouseover and nothing happens. If I change the alert target to anything at the parent window level, no problem...including of course the iframe tag itself (not the contents of that frame) and attributes assigned to it.
Last edited by ineloquucius : October 5th, 2009 at 08:05 AM.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|