change a style in firefox with javascript

  • halfasleeps
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Feb 17, 2006
  • Posts: 13
  • Status: Offline

Post June 6th, 2006, 11:13 am

i have this style

<div id="diamonds" style="position:absolute; left:0px; top:0px; width:130px; height:255px; z-index:1; visibility: hidden;">

i have a function that changes it with javascript

b.left=X_pos;
b.top=Y_pos;
alert('X_pos= '+X_pos+' left= '+b.left+' Y_pos= '+Y_pos+' top= '+b.top);

it changes the left and top to a new number, in IE it sees tghe new number and changes the left and top to the new number, however in firefox it DOES see the new number (it know what X_pos is) but it does not change the style to the new number.... so i guess this is how you change the style in IE so how do i change the style in firefox?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 6th, 2006, 11:13 am

  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post June 6th, 2006, 12:07 pm

Try b.style.left and b.style.top respectively.
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • halfasleeps
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Feb 17, 2006
  • Posts: 13
  • Status: Offline

Post June 6th, 2006, 12:13 pm

thanks for your reply

b is the actual css style declaration object

if i do this
b.left=255;
b.top=255;
alert(b.top);


IE says : 255px
FF says : 0px
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post June 6th, 2006, 12:17 pm

halfasleeps wrote:
thanks for your reply

b is the actual css style declaration object

if i do this
b.left=255;
b.top=255;
alert(b.top);


IE says : 255px
FF says : 0px


Ah, wasn't very clear from the code you posted. With firefox, you may have to specify the units concatenated onto the value, i.e.:

Code: [ Select ]
b.left = 255 + "px";
b.top = 255 + "px";
  1. b.left = 255 + "px";
  2. b.top = 255 + "px";
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • halfasleeps
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Feb 17, 2006
  • Posts: 13
  • Status: Offline

Post June 6th, 2006, 12:19 pm

THANK YOU SO MUCH you saved me!...i been trying to many things to figure it out and all i needed to do was add px to the end....whoo
  • Bozebo
  • Expert
  • Expert
  • User avatar
  • Joined: Feb 15, 2006
  • Posts: 709
  • Loc: 404
  • Status: Offline

Post June 6th, 2006, 12:24 pm

a good way to make it would be to make more than one stylesheet with different names then use cookies and pull the cookies in with the rel="" in order for it to catch the correct stylesheet, doign it this way will make it compatable on all browsers, many browsers fail to work with some javascript things
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post June 6th, 2006, 12:33 pm

Bozebo wrote:
a good way to make it would be to make more than one stylesheet with different names then use cookies and pull the cookies in with the rel="" in order for it to catch the correct stylesheet, doign it this way will make it compatable on all browsers, many browsers fail to work with some javascript things


I don't think that's anything to do with halfasleep' problem. He's changing the content of his page dynamically using JavaScript - not something you can do with CSS files.
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • halfasleeps
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Feb 17, 2006
  • Posts: 13
  • Status: Offline

Post June 6th, 2006, 12:52 pm

katana wrote:
Bozebo wrote:
a good way to make it would be to make more than one stylesheet with different names then use cookies and pull the cookies in with the rel="" in order for it to catch the correct stylesheet, doign it this way will make it compatable on all browsers, many browsers fail to work with some javascript things


I don't think that's anything to do with halfasleep' problem. He's changing the content of his page dynamically using JavaScript - not something you can do with CSS files.


correct bc i am setting a drop down menu to be placed right under the button that calls it. it used to be a static x and y but i made it so i can move the button around and the drop down menu follows it.

[OT]
katana, lol @ the thing in your sig 31 Oct = 25 Dec, thats clever
[/OT]
  • Bozebo
  • Expert
  • Expert
  • User avatar
  • Joined: Feb 15, 2006
  • Posts: 709
  • Loc: 404
  • Status: Offline

Post June 6th, 2006, 1:03 pm

Quote:
katana, lol @ the thing in your sig 31 Oct = 25 Dec, thats clever


:S i still do not understand that partiular joke and or pun and i am also speaking exactly in this specific way because the moderator seems to hate the occasional l - o - l (ok enough of that not... sort of taking it too far) well ehm im pushign it now lol. but ehm an incident happened a few minutes ago about the chatspeak...

ok back to the matter at hand, maby i should pm about this but ill embarass myself here... i sont understand ur signature. is it somethign to do with the time / date functions or something? lol



ok and sorry about what i said highlighted in the quote in the quote then confirmed by the person who made the seccond set of quotes. i jumped to conclusions, user-custom styles are a common thing people ask for.
  • katana
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 07, 2004
  • Posts: 2390
  • Loc: Edinburgh, Scotland
  • Status: Offline

Post June 6th, 2006, 1:09 pm

Oct is shorthand for Octal, which is base-8. Dec is short for Decimal. 31 Octal = (3*8 )+1 which is equal to 25 Decimal.
Haven't you covered different bases in computing at school?
Why do geeks get Halloween and Christmas confused?
Because 31 Oct == 25 Dec
www.darren-king.co.uk
  • Bozebo
  • Expert
  • Expert
  • User avatar
  • Joined: Feb 15, 2006
  • Posts: 709
  • Loc: 404
  • Status: Offline

Post June 6th, 2006, 1:12 pm

nope not at all... and im in the highest possible class at school... hmmm... but i am very good at visual basic... which they tought TOO much lol.


edit:
guess that means im not a geek then lol :roll: althoguth...

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 576 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.