Print Page | Close Window

why wont this js work in Firefox

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=10654
Printed Date: 28 March 2026 at 2:20pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: why wont this js work in Firefox
Posted By: dj air
Subject: why wont this js work in Firefox
Date 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



Replies:
Posted By: Semikolon
Date 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!


Posted By: dj air
Date 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


Posted By: dj air
Date 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



Posted By: dj air
Date 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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net