469,645 Members | 1,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

inspecting the iframe

Is it possible for javascript to inspect the contents of an iframe or
is it an external object?

<iframe id="myiframe" src="">

<script>
document.getElementById.myiframe.src =
"http://www.wherever.com/foo.php"
</script>

I can set the src of the iframe from javascript, can I read the
results, assuming the iframe returns some text?

like with frames you can nest the document object,
mytext = document.getElementById.myiframe.document.body

Herc

Jul 23 '05 #1
2 1813
he*****@hotmail.com wrote:
Is it possible for javascript to inspect the contents
of an iframe or is it an external object?
So long as cross-domain security restrictions don't apply, it is
possible to access the window object within an IFRAME through the -
frames - collection of the containing window object.
<iframe id="myiframe" src="">
However, of you want to access IFRMAE content through the - frames -
collection as a named property of the collection you would be better off
giving the IFRAME an additional name attribute that correspo0nds with
its ID.
<script>
Valid HTML 4 requires SCRIPT elements to have a TYPE attribute.
document.getElementById.myiframe.src =
It is extremely unlikely that the function object that is the
getElementById method of the document will have a property named
'myiframe'. You should be calling the getelementById method at this
point an passing the ID of the element to it as a string.
http://www.wherever.com/foo.php
By W3C HTML DOM standard assigning a value to the - src - property of an
IFRAME is a meaningless and pointless activity (i.e. cannot be expected
to provide useful or consistent results across DOM standard browsers
(and doesn't)). Navigating IFRAMEs is best done by assigning to the -
location - property of their correspo0nding window object.
</script>

I can set the src of the iframe from javascript,
But you probably shouldn't expect that to do anything useful.
can I read the
results, assuming the iframe returns some text?

like with frames you can nest the document object,
mytext = document.getElementById.myiframe.document.body


frames['myiframe'].document.body

- assuming you give the IFRAME a NAME attribute of "myiframe".

Richard.
Jul 23 '05 #2
This is how I was running a basic shoutbox

document.getElementById("if1").src =
"http://www.ch3ss.com/test/chat.php?say=" + document.chat.say.value

chat.php just adds the say.value to a text file and echoes the file.
(its offline now incase people send it junk).

I can't seem to get frames["myiframe"}.document.body to return
anything, Access is denied, I tried changing permissions.

Herc

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Christopher J. Hahn | last post: by
3 posts views Thread by Angel | last post: by
1 post views Thread by Z1P2 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.