473,396 Members | 2,002 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,396 software developers and data experts.

iFrame.offsetWidth is not working expectedly.

dmjpro
2,476 2GB
Here is my HTML code ..

Expand|Select|Wrap|Line Numbers
  1. <iframe src="reference_page.html" id="test_fr"></iframe>
  2.  
Have a look at my reference HTML code

Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <div style="height:700px;width:800px">
  3. </div>
  4. </body>
  5.  
Now my Java Script code ..

Expand|Select|Wrap|Line Numbers
  1. var iFrame = document.getElementById('test_fr');
  2. alert(iFrame.contentDocument.body.offsetWidth+'\t'+iFrame.contentDocument.body.offsetHeight);
  3.  
Now my JS code gives me offsetHeight properly..means 700.
But offsetWidth is not ..
What's the cause ?
Aug 24 '09 #1
5 4260
Dormilich
8,658 Expert Mod 8TB
@dmjpro
what does it give and what do you expect?
Aug 24 '09 #2
dmjpro
2,476 2GB
@Dormilich
It gives a value which is not 800 as offsetHeight given ... ;)
Aug 24 '09 #3
Dormilich
8,658 Expert Mod 8TB
so, what does it give instead (I may draw a conclusion from that…)?
Aug 24 '09 #4
dmjpro
2,476 2GB
@Dormilich
267 in firefox 2.
How does it help to draw a conclusion .. ?
Aug 24 '09 #5
dmjpro
2,476 2GB
Well, I able to configure the solution, not the reason.
Still waiting for the reason ;)
Now i am calculating the width of a Body ....

Expand|Select|Wrap|Line Numbers
  1. var iFrame = document.getElementById('frame_id');
  2.     //alert(iFrame.contentDocument.body.firstChild.offsetWidth);
  3.     var maxWidth = 0;
  4.     var children = iFrame.contentDocument.body.childNodes;
  5.     alert(children.length);
  6.     for(var i=0;i<children.length;i++){
  7.         if(children[i].offsetWidth && children[i].offsetWidth>maxWidth) maxWidth = children[i].offsetWidth;
  8.     }
  9.     alert(maxWidth);
  10.  
Aug 25 '09 #6

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

Similar topics

9
by: Julia Briggs | last post by:
How do I construct a <iframe> or equivalent for FireFox/NS browsers, inside a screen centered <div> tag? Can it be done?
3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
2
by: Per Jessen | last post by:
This is a javascript question, possibly somewhat inappropriate for this group, but here we go: (please redirect me to the right place to ask). In Microsoft Internet Explorer (5 and up) using...
1
by: Kuv patel | last post by:
Hi I am displaying a page inside an Iframe, and I would like to enlarge the iframe window to the size of the browser when the browser window loads up. In the onload event of the browser I am...
3
by: Paul Fi | last post by:
i want the scrollbars of my aspx page to be the scrollbars of the iframe i set inside the page is that possible? or is there any workaround on this issue? *** Sent via Developersdex...
3
by: Prasad | last post by:
Hi , I am using a cross domain iframe in my page.. If i want to change the iframe height a/c to its content height , its giving Permission denied error as i am trying to access a function, which ...
3
by: reflex | last post by:
Hi, i am using onmouse tooltip on my website. Under them i use iframe to hide form elements if is tooltip above them. Everything works fine only at firefox there is +-1sec "refresh" when tooltip...
5
by: liketofindoutwhy | last post by:
for the code var node = document.getElementById("something") alert(node.offsetWidth) is very similar to node.clientWidth and node.scrollWidth I just wonder why offsetWidth is well...
4
dmjpro
by: dmjpro | last post by:
HTML code <div id="dtls_DIV" style="background-color:#CCCCCC;border-style:solid;border-width:1px;border-color:#000000;display:none;position:absolute;height:180px;width:230px;overflow:auto"> ...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.