473,399 Members | 4,177 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,399 software developers and data experts.

Accessing elements of IFrame..

dmjpro
2,476 2GB
I want to access the elements of IFrame.
Suppose here is my code ....
Expand|Select|Wrap|Line Numbers
  1. <iframe .... ></iframe>
  2.  
Now i want to access the elements inside the IFrame ..how can i do that ?
Oct 13 '08 #1
5 2140
acoder
16,027 Expert Mod 8TB
For standards-compliant browsers, use contentDocument to get access to the document within the iframe. IE requires contentWindow.document.

If you use the window.frames[] syntax, you can just use document.
Oct 13 '08 #2
dmjpro
2,476 2GB
For standards-compliant browsers, use contentDocument to get access to the document within the iframe. IE requires contentWindow.document.

If you use the window.frames[] syntax, you can just use document.
Why JavaScript comes up with two flavors?
Oct 15 '08 #3
acoder
16,027 Expert Mod 8TB
No, JavaScript doesn't come with two flavours. Browsers sometimes choose not to implement standards which is where things go wrong and, more often than not, it's IE which is the culprit. There are parts of JavaScript where there are no standards at present. In that case, browsers have to come to some sort of agreement on naming, behaviour, etc.

Edit: did you mean the two different types of syntax?
Oct 15 '08 #4
dmjpro
2,476 2GB
No, JavaScript doesn't come with two flavours. Browsers sometimes choose not to implement standards which is where things go wrong and, more often than not, it's IE which is the culprit. There are parts of JavaScript where there are no standards at present. In that case, browsers have to come to some sort of agreement on naming, behaviour, etc.

Edit: did you mean the two different types of syntax?
Sorry you didn't get me ... ;)
Suppose this is my code ..
Expand|Select|Wrap|Line Numbers
  1. <iframe name='_name' id='_id' ... ></iframe>
  2.  
Now i am accessing the document object of IFrame ...
Expand|Select|Wrap|Line Numbers
  1. var doc = document.getElementById('_id').contentDocument; //Mozilla
  2. var doc = document.getElementById('_id').contentWindow.document //IE
  3. var doc = window.frames['_name'].document; //both
  4.  
Now my question is ..that
document.getElementById('_id') and window.frames['_name'] refers the same object ..i mean the iIFrame window.

For one case contentDocument or contentWindow.document and for another case it is cimply document ..why?
This is my question ?
I think you get my question ... ;)
Oct 15 '08 #5
acoder
16,027 Expert Mod 8TB
This link will explain. It boils down to whether it's a frame or an object. The first syntax is used for an object while the second for a frame.
Oct 15 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Julius Mong | last post by:
Dear all, I have something like this: <html... > <embed ...> </html> Am I out of luck if I wanted to access the embedded DOM and manipulate its content? Or if I have:
1
by: BGMeshi | last post by:
Hi, The following javascript code (serving a main HTML page) dynamically creates IFRAME to contain other HTML page. Everyting works OK, however when I am trying to access the main HTML page...
1
by: R | last post by:
Hello, I have a frame in which there are 2 IFrames., both being loaded from the same domain. One IFrame is loaded from http://test1.xyz.com and the other IFrame is loaded from...
4
by: Paul Brant | last post by:
Hi all, I have a page with an IFRAME in it. From a script in the main ( parent ) page I instruct the IFRAME to load a specific URL. The URL contains parameters that are processed by the server....
6
by: NoCopy na | last post by:
Using the following example: domiframetest.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
22
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements:...
19
by: k.karthikit | last post by:
Hello all, In some hidden variable (<input type="hidden" name="hiddenId" value="test" /> ,i stored some value.I accessed the value "test" using var id = document.getElementById( 'hiddenId' );...
14
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
2
dorinbogdan
by: dorinbogdan | last post by:
Let's say that my IFrame has id="container". I can get a reference to it using var ref = document.getElementById("container"); I can get an array of all elements using: ref.document.all But,...
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: 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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.