473,387 Members | 1,899 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.

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 21336
gits
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
gits
5,390 Expert Mod 4TB
congrats ;) you find it the same time for yourself ;)

kind regards
Jul 1 '07 #3
drhowarddrfine
7,435 Expert 4TB
Yes, units are required for html and css as the standard so states.
Jul 1 '07 #4
acoder
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)
  3.  
  4. {
  5.  
  6.     if (window.pageYOffset)
  7.  
  8.         ScrollTop = window.pageYOffset;
  9.  
  10.     else
  11.  
  12.         ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
  13.  
  14. }
  15.  
  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
acoder
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

2
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...
2
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...
3
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)...
21
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...
13
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...
5
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...
8
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 +...
15
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...
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,...

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.