473,396 Members | 2,013 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.

My element.style.top assignment is not working in Firefox

Sorry, I have found my mistake, but I cannot delete this post.
I have discovered by experiment that element.style.top assignment in IE works with just a number on the right but in Firefox you have to put the unit too. Original code is below. Adding "+'px'" made it work in Firefox too.
Expand|Select|Wrap|Line Numbers
  1. javascript
  2.     var fullsizeimage = document.getElementById('fullsizeimageframe');
  3.     if (!fullsizeimage) return false;
  4.     var coord = new Array(2);
  5.     coord = findPos(whichpic);
  6.     alert(coord[1]);
  7.     alert(fullsizeimage.offsetTop);
  8.     document.getElementById('fullsizeimageframe').style.top = coord[1]; 
  9.     alert(fullsizeimage.style.top);
  10.   .....
alert results IE: 162; -2; 162px (div moves)
alert results Firefox 2: 162; 0; blank (div doesn't move)
Jul 1 '07 #1
8 21344
5,390 Expert Mod 4TB
hi ...

i think you have to set explicitly:

Expand|Select|Wrap|Line Numbers
  1. ele_ref.style.top = 'width px';
so add + 'px' to your set-statement ...

kind regards
Jul 1 '07 #2
5,390 Expert Mod 4TB
congrats ;) you find it the same time for yourself ;)

kind regards
Jul 1 '07 #3
7,435 Expert 4TB
Yes, units are required for html and css as the standard so states.
Jul 1 '07 #4
16,027 Expert Mod 8TB
Sorry, I have found my mistake, but I cannot delete this post.
I'm sure this will help someone, so it makes sense not to delete it.
Jul 2 '07 #5
Hi friends,
I have faced same issues.But it not work for me in FF. In bellow my code even if ScollTop greater than 0 it is not work

Expand|Select|Wrap|Line Numbers
  1.  var ScrollTop = document.body.scrollTop;
  2.         if (ScrollTop == 0)
  4. {
  6.     if (window.pageYOffset)
  8.         ScrollTop = window.pageYOffset;
  10.     else
  12.         ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
  14. }
  16.         shadow.style.top = ScollTop +'px';
  17.         shadow.style.left = 0;
May 2 '09 #6
Sorry Guys. it work me too
May 2 '09 #7
16,027 Expert Mod 8TB
Welcome to Bytes. Glad you managed to solve it. I assume the problem was a mis-spelling.

PS. please remember to use [code] tags when posting code. Thanks.
May 2 '09 #8
i registered just to say u saved my day.
a million thanks!
Jun 29 '14 #9

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

Similar topics

by: Jeff Gutsell | last post by:
Occasionally, in creating a static page I have assigned two classes to an element. For example: "class = 'BodyText Note'." It's a neat way of streamlining my stylesheets. However, I have never...
by: lawrence | last post by:
I've a graphic designer who wants to be able to see what he's styled and what he so far hasn't. So I'd like to write a script that will work in, say, FireFox, so that he can point FireFox at has...
by: abs | last post by:
Hi all. I use such code to clone blocks: element = document.getElementById(IdOfElement) element = element.cloneNode(true) new_element = document.getElementById(IdOfElement).appendChild(element)...
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
by: Mounir | last post by:
Hi, Assume that right and left are multiple select elements. It's about the following line : right.options=left.options; It copies the content of left.options into right.options, but...
by: eholz1 | last post by:
Hello , I have a web page that has a div element, with css applied to that element. Within the div is an ul with li tags, etc. the displayed font size in IE is larger than the the font size in...
by: Sunny | last post by:
Hi, I am creating an Element on page in Firefox. But It gives me an error in Firefox. String contains an invalid character" code: "5 county = document.createElement('"' + countyVMLtext +...
by: Sunny | last post by:
Hi, I can change the lement opacity in IE using. abc.style.filter = 'alpha(opacity=' + 10 + ')'; But this dont work in firefox, In firefox it throws error. How I can change the opacity of an...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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,...
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...
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...
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.