473,698 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.boby.o ffsetWidth getting different value.

2,476 Top Contributor
I am testing the value of document.body.o ffsetWidth in Mozilla and IE.
IE gets the desired value but Mozilla is not getting the desired value.
Actually what happens, i want to position an element at the right most of the screen.In IE the element positioned properly whether the screen has scroll or not, but Mozilla positions the element but not at the rightmost if the screen has scroll.
Can anyone figure it out why it happens ?
Nov 4 '08 #1
3 2567
16,027 Recognized Expert Moderator MVP
Can you post the code that you're working with? You may find this page useful.
Nov 4 '08 #2
2,476 Top Contributor
Can you post the code that you're working with? You may find this page useful.
Thanks for reply.. ;)
Here is my HTML code ....
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0);" onclick="closeWindow('<%=request.getParameter("cal_event_type")%>')"><img alt="Cross" src="./img/cross.JPG" id="cross_image" title="Cross the window" style="height:7px;width:7px"/></a>
I am repositioning the cross image when page gets loaded...that means during onLoad event.

Here is my JavaScript code ..
Expand|Select|Wrap|Line Numbers
  1. var cross_image_ref = document.getElementById('cross_image');
  2. cross_image_ref.style.position = 'absolute';
  3. cross_image_ref.style.left = document.body.offsetWidth+'px';
Remember if the screen is having horizontal scroll then it does not work in Mozilla but it works expectedly in IE.
Why it differs ..please help!

By the way i solved this problem .... I know that in the page which causes the scroll bars.. i am having the width of that element and reposition the image ..
but it's not a feasible solution ..what do you think ? ..... ;)
Nov 4 '08 #3
rnd me
427 Recognized Expert Contributor
you might have better luck with a more resiliant, doctype proof assesment of the width:

Expand|Select|Wrap|Line Numbers
  1. IE=false;   //@cc_on; IE=true; 
  3.      if(IE){ window.innerHeight = parseInt(document.documentElement.clientHeight || document.body.clientHeight) ; }
  5.     if(IE){ window.innerWidth = parseInt(document.documentElement.clientWidth || document.body.clientWidth); }
this adds the w3 innerWidth value to IE under either quirks or strict rendering.

you can also use style.right = "2%" to hug the right side, lots of people forget about that and use 98% left instead...
Nov 4 '08 #4

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

Similar topics

by: Gary Mayor | last post by:
Hi, I'm re phrasing and earlier question as the earlier question doesn't make to much sense. I using document.onmousemove to move a <div line on the screen. At the moment if I click and move the mouse over the image it doesn't move the line but if I click off the image and move the mouse the line moves like it's supposed to. Also if I click it off the image and move the mouse over the image it then works. Something on clicking the image...
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
by: parksch2 | last post by:
I know there are a lot of articles out there about this subject but I have been reading for 3 hours and still can't find the answer. I have some text in a bunch of hidden spans. I need to find the width in pixels of that text. Using offsetWidth gives me a different value when viewed in IE and Firefox. I need those to sync up somehow. I have tried innerWidth, clientWidth, scrollWidth, etc. Any ideas? Thanks in advance!
by: dd | last post by:
Hello all. First, I'm a newbie to javascript but not to ASP. Secondly I've been searching for the answer for two hours and I decided to finally post this question. I'm trying to take a javascript and make it work with asp. Any thought, ideas or pointers in the right direction would be greatly appreciated. I am getting the following error: Microsoft JScript runtime error '800a1391'
by: Captain Dondo | last post by:
Is it possible to get the actual document size? Not the window size, but the actual rendered document size, which in my case is bigger than the window. I am trying to set up a form entry system where the user scrolls by the UP and DOWN keys. The idea is to keep as much context on the screen. Say the form has 15 lines, and 7 are displayed. The user starts on line 1, at the top of the screen. The text on the screen stays fixed, until...
by: kuldeep bajaj | last post by:
Hi, I have developed one custom dropdown JSP tag just as HTML select box . I calculate width of dropdown box using div's offsetWidth attribute. But I am getting it's value as zero inside table tag .Outside the table it is returning proper width What would be the reason of not getting proper offsetWidth of DIV inside TABLE? Please give me suggestion. Thanks, Kuldeep
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the internet. When I run Firebug on it, it says: document.getElementById("TICKER") has no properties TICKER_CONTENT = document.getElementById("TICKER").innerHTML; Here is the complete script:
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 documented in the Definitive Javascript book, but clientWidth and scrollWidth are not mentioned at all, even when all 3 of them work in IE6, IE 7, Firefox 2, and Safari
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.