473,772 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My element.style.t op assignment is not working in Firefox

2 New Member
Sorry, I have found my mistake, but I cannot delete this post.
I have discovered by experiment that element.style.t op 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 21465
gits
5,390 Recognized Expert Moderator Expert
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 Recognized Expert Moderator Expert
congrats ;) you find it the same time for yourself ;)

kind regards
Jul 1 '07 #3
drhowarddrfine
7,435 Recognized Expert Expert
Yes, units are required for html and css as the standard so states.
Jul 1 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
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
akshalika
17 New Member
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
akshalika
17 New Member
Sorry Guys. it work me too
May 2 '09 #7
acoder
16,027 Recognized Expert Moderator MVP
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
zshowing
1 New Member
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
2092
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 been able to use JavaScript to dynamically add a second class to an element. I'm guessing that this involves some string concatenation, and I must be making some silly mistake. The type of approach I've tried has been: theElement.className =...
2
1402
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 websites and the script will loop through the page after its loaded and perhaps for each element do something like throw an alert() with the style rules. I can call the style() method on each element to get its rules, but how do I get every element?
3
6966
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) Anybody knows how to set id for the new element ? I mean the id which I coud use in CSS stylesheet for setting css properties of new element.
21
3990
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 nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
13
1848
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 *removes* the content of the first one !
5
10101
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 firefox. Needless to say the code for the page in question is the same. I would like to font size to be the same for both browsers.
8
3156
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 + '"'); I am adding a SVG shape to the page. Here is the Shape :
15
3728
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 element in Firefox.
0
9454
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,...
0
10264
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, 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...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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,...
0
9914
tracyyun
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...
0
8937
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, 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...
0
6716
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();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.