Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - why wont this js work in Firefox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closedwhy wont this js work in Firefox

 Post Reply Post Reply
Author
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Direct Link To This Post Topic: why wont this js work in Firefox
    Posted: 28 May 2004 at 3:04pm
i have the following javascript and it works in IE 6 but wonk work in firefox can anyone shed some light on this?

function ColourChangerEven() {
    Even.style.backgroundColor = document.frmRegister.Remote_Listing_Even.value;
    Even2.style.backgroundColor = document.frmRegister.Remote_Listing_Even.value;

}


Even and Even2 are both ID values

what the js does is when prompted sets the ID values backgrounds to the colour of the even form field value (hex colour). but it doesn't do anything in firefox.

can anyone help with whats wrong
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Direct Link To This Post Posted: 28 May 2004 at 5:34pm
I have no idea.. but I have sort of the same problem with style.display='block/none'.. or maybe it was everything inside the style tag.. don't remember.. works in Opera and IE, but not in firefox!
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Direct Link To This Post Posted: 29 May 2004 at 5:56am
it looks like it is something to do with the style tag.  i think if you use the

Javascript fnction name (this)

then that would work (borg uses it on his menu system) and that works, its because it can't identify it like

it can find document.form.field name.

but it can't find Identifier.sytle .. i think it can't be done or it needs something before it like ID.Identifier.style

Identifier is the ID name like Even
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Direct Link To This Post Posted: 30 May 2004 at 3:06pm

good news it just came to be a minute ago how to do it.

heres what my code would need to be to work


function ColourChangerEven() {

<%
If Request.ServerVariables("HTTP_USER_AGENT") = "winIE5" Then
%> 
 document.all.Even.style.backgroundColor = document.frmRegister.Remote_Listing_Even.value;
 document.all.Even.style.backgroundColor = document.frmRegister.Remote_Listing_Even.value;

<%

'Else for all other browsers use document.getElementById
Else

%>
 document.getElementById("Even").style.backgroundColor = document.frmRegister.Remote_Listing_Even.value;
 document.getElementById("Even2").style.backgroundColor = document.frmRegister.Remote_Listing_Even.value;

<%
End If

%>

}

all you need to do is give the Item you want to change, an ID value then using the above examople change all part from the bold section (apart from the ID value)

then it will work with any, get the element:D

Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Direct Link To This Post Posted: 31 May 2004 at 2:31pm
Does anyone have any idea why this works in IE but not in Firefox,

document.getElementById("HeadingImage1").background = document.frmRegister.Remote_Header_BG.value;

but

document.getElementById("HeadingImage1").style.backgroundColor = document.frmRegister.Remote_Header.value;

works in both,

ive tried using the .style.background =
to change the background image and that doesn't work aswell. im running out of ideas.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.