473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

IE and iframe

Hi,

I am calling an iframe from my parent document. In the parent document,
i used the following script to get the value of the textfield present
in the iframe. This doesn't seem to work in IE.

Please advise.
window.frames['myframe'].document.getElementsByName('mytextfield')[0].value

Thanks for your help,
Dev.

Nov 21 '06 #1
10 1777
ka**********@gmail.com escreveu:
I am calling an iframe from my parent document. In the parent document,
i used the following script to get the value of the textfield present
in the iframe. This doesn't seem to work in IE.

Please advise.

window.frames['myframe'].document.getElementsByName('mytextfield')[0].value
<iframedoesn't behave like the <frame>, so you won't find your
<iframeinside the "window.frames" collection.

Grab your <iframeby using getElementById ^^
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Nov 21 '06 #2
Jonas Raoni wrote:
ka**********@gmail.com escreveu:
>I am calling an iframe from my parent document. In the
parent document, i used the following script to get the
value of the textfield present in the iframe. This doesn't
seem to work in IE.

Please advise.

window.frames['myframe'].document.getElementsByName('mytextfield')
[0].value

<iframedoesn't behave like the <frame>, so you won't find your
<iframeinside the "window.frames" collection.
You can reference the window object contained in an IFRAME through the
global - frames - collection, by integer index and by NAME attribute
(but not by ID attribute) in IE.
Grab your <iframeby using getElementById ^^
A reference to an IFRAME element is not the same as a reference to the
global/window object contained in the IFRAME.

Richard.
Nov 21 '06 #3
ka**********@gmail.com wrote:
Hi,

I am calling an iframe from my parent document. In the parent document,
i used the following script to get the value of the textfield present
in the iframe. This doesn't seem to work in IE.

Please advise.
window.frames['myframe'].document.getElementsByName('mytextfield')[0].value

Thanks for your help,
Dev.
getElementsByName doesn't exist in any standard. So I wouldn't use that
if I were you.

Also note that if the iframe is served by another (sub)domain, it would
be considered cross-site scripting, which is almost always blocked.

--
Martijn Saly
Nov 21 '06 #4
Martijn Saly wrote:
ka**********@gmail.com wrote:
<snip>
>window.frames['myframe'].document.getElementsByName('mytextfield')[0].value
<snip>
getElementsByName doesn't exist in any standard. So I wouldn't use that
if I were you.
<snip>

If the W3C HMTL DOM level 1 and 2 recommendations are not enough of a
standard for you what exactly does "exist in any standard"?

Richard.

Nov 21 '06 #5
Richard Cornford wrote:
Martijn Saly wrote:
>ka**********@gmail.com wrote:
<snip>
>>window.frames['myframe'].document.getElementsByName('mytextfield')[0].value
<snip>
>getElementsByName doesn't exist in any standard. So I wouldn't use that
if I were you.
<snip>

If the W3C HMTL DOM level 1 and 2 recommendations are not enough of a
standard for you what exactly does "exist in any standard"?

Richard.
Oops, I guess I overlooked that one. But in any case, on this page
you'll find that getElementsByName is not-so-safe-to-use no matter if
it's defined in any standard or not:

http://www.quirksmode.org/dom/w3c_core.html

(sorry, no anchors on the page... it's near the end)
--
Martijn Saly
Nov 21 '06 #6
Richard Cornford escreveu:
Jonas Raoni wrote:
><iframedoesn't behave like the <frame>, so you won't find your
<iframeinside the "window.frames" collection.

You can reference the window object contained in an IFRAME through the
global - frames - collection, by integer index and by NAME attribute
(but not by ID attribute) in IE.
I didn't knew about it, maybe because I never used the <iframehaha.

I just tested and both "id" and "name" worked on IE and Opera, but on
Firefox 2, it's added to the collection only if I use the name property.
>Grab your <iframeby using getElementById ^^

A reference to an IFRAME element is not the same as a reference to the
global/window object contained in the IFRAME.
Yes, it's needed to access the contentWindow.
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Nov 22 '06 #7
Jonas Raoni wrote:
Richard Cornford escreveu:
>Jonas Raoni wrote:
>><iframedoesn't behave like the <frame>, so you won't
find your <iframeinside the "window.frames" collection.

You can reference the window object contained in an IFRAME
through the global - frames - collection, by integer index
and by NAME attribute (but not by ID attribute) in IE.

I didn't knew about it, maybe because I never used the
<iframehaha.
You declared that " <iframedoesn't behave like the <frame>, so you
won't find your <iframeinside the "window.frames" collection" based
upon zero practical experience of applying scripting to DOM
representations of IFRAME elements? Doesn't that strike you as folly,
and likely harm you credibility?
I just tested and both "id" and "name" worked on IE and
Opera, but on Firefox 2, it's added to the collection
only if I use the name property.
And if you try it on another dozen scriptable browsers you will find
pretty much the same pattern, where an IFRAME with a NAME attribute can
reliably be referenced using that name in the containing window's -
frames - collection. It is the single most reliable approach for
referencing IFRAMEs that is arable (is unknown to fail in any scriptable
browser that can employ IFAMES in the first place.
>>Grab your <iframeby using getElementById ^^

A reference to an IFRAME element is not the same as a
reference to the global/window object contained in the IFRAME.

Yes, it's needed to access the contentWindow.
But when a general strategy is available using an alternative that is
both non-standardised and only available on the newest of browsers is
acting to significantly restrict the potential of the outcome for no
good reason.

Richard.
Nov 26 '06 #8
Martijn Saly wrote:
Richard Cornford wrote:
>Martijn Saly wrote:
>>ka**********@gmail.com wrote:
<snip>
>>>window.frames['myframe'].document.
getElementsByName('mytextfield')[0].value
<snip>
>>getElementsByName doesn't exist in any standard. So
I wouldn't use that if I were you.
<snip>

If the W3C HMTL DOM level 1 and 2 recommendations are not
enough of a standard for you what exactly does "exist in
any standard"?
<snip>
Oops, I guess I overlooked that one. But in any case, on this page
you'll find that getElementsByName is not-so-safe-to-use no matter if
it's defined in any standard or not:

http://www.quirksmode.org/dom/w3c_core.html
<snip>

There may be good reasons for not using - getElementsByName - (not least
the more reliable alternatives) but not being part of a standard is not
one of them.

Richard.
Nov 26 '06 #9
Richard Cornford escreveu:
Jonas Raoni wrote:
You declared that " <iframedoesn't behave like the <frame>, so you
won't find your <iframeinside the "window.frames" collection" based
upon zero practical experience of applying scripting to DOM
representations of IFRAME elements?
Yep, I trusted in my thought :]
Doesn't that strike you as folly,
and likely harm you credibility?
Ah, I'm not looking for credibility, most of the times I answer things
without testing. It really doesn't matter what people think of me, I
don't want to look like a JS guru, I'm here mainly to spend some free
time, I just offer my knowledge and ideas ;]
And if you try it on another dozen scriptable browsers you will find
pretty much the same pattern, where an IFRAME with a NAME attribute can
reliably be referenced using that name in the containing window's -
frames - collection.
For sure, but I won't do it, I just have those 3 browsers. ^^
>>A reference to an IFRAME element is not the same as a
reference to the global/window object contained in the IFRAME.
Yes, it's needed to access the contentWindow.

But when a general strategy is available using an alternative that is
both non-standardised and only available on the newest of browsers is
acting to significantly restrict the potential of the outcome for no
good reason.
Look that I didn't told the OP to use the contentWindow (if I didn't
knew about <iframesbeing accessible through window.frames, I would do
it though), I just "answered" your affirmative.
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Nov 26 '06 #10
Richard Cornford wrote:
Martijn Saly wrote:
>Richard Cornford wrote:
>>Martijn Saly wrote:
ka**********@gmail.com wrote:
<snip>
window.frames['myframe'].document.
getElementsByName('mytextfield')[0].value
<snip>
getElementsByName doesn't exist in any standard. So
I wouldn't use that if I were you.
<snip>

If the W3C HMTL DOM level 1 and 2 recommendations are not
enough of a standard for you what exactly does "exist in
any standard"?
<snip>
>Oops, I guess I overlooked that one. But in any case, on this page
you'll find that getElementsByName is not-so-safe-to-use no matter if
it's defined in any standard or not:

http://www.quirksmode.org/dom/w3c_core.html
<snip>

There may be good reasons for not using - getElementsByName - (not least
the more reliable alternatives) but not being part of a standard is not
one of them.

Richard.

Of course that's a good reason. Unless you want to keep fixing your
website for every update of a certain browser made by a certain big company.

--
Martijn Saly
Nov 28 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Csaba2000 | last post by:
I want to be able to embed a single quote into an INPUT element within a dynamically generated IFRAME. The example below shows how the IFRAME is generated. Challenge: I'd like the alert box to...
4
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I...
2
by: Templar | last post by:
Hi i'm bothering with such problem... I must dynamic create an Iframe, and then put som raw HTML into it. But I can't. When I create iframe, I can't access its properties. Here's the coe...
1
by: Martin | last post by:
There seems to be some strange behaviour when trying to get the scrollHeight and scrollTop of an iframe in IE6. I have tried several ways of getting these values when the iframe is written into...
7
by: Christopher J. Hahn | last post by:
I'm trying to use a script-generated form to submit to a script-generated iframe. The problem I'm running into is that the iframe is not assuming the name I assign it. IE6 on Win2000. FF1.0.2+...
3
by: Angel | last post by:
How do I get the reference of the IFrame from the asp.net webpage that is being displayed within that IFrame? In other words I have an IFrame in my page. Within that IFrame Set the source to a...
0
by: tequilamala | last post by:
I have an Iframe in one of the pages i am developing... the iframe is suppose to scroll up and down and the links target the iframe. the problem is that the iframe scrolls side to side on internet...
1
by: Z1P2 | last post by:
I would like to gradually resize an iframe in an onmouseover event. I can easily do it with an image, but when I try to do it with an iframe, it doesn't do anything. So first of all, is it possible...
1
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to...
23
by: vunet | last post by:
It is recommended by some sources I found to create IFrames in IE using document.createElement('<iframe src="#">') instead of document.createElement('iframe'). Why and what browser versions to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.