Simon wrote:
I have recently set up a server certificate on a web site.
Under certain conditions I need to change the color of a html span
element.
I do this using the following javascript function called from the
onreset attribute of the form element.
function removeWarningMsg()
{
if (isIE) {
document.all.Warning.style.color = "<%=BACKGROUND_COLOUR%>";
}
return true;
}
This was working perfectly fine until I applied the server certificate
to the website.
Now when executing this line of code the following error occurs:
Error: 'document.all.warning.style' is null or not an object.
I am fairly new to both Javascript and SSL so if anyone could throw
any light on to what the issue may be it would be greatly appreciated.
regards Simon
View the source, is the page still producing a <span id="Warning">? If so, are
you using document.all.Warning... or document.all.warning... (the error you
pasted seems to imply the latter). HTML element ids are case-sensitive, so
that's the first thing to check.
Lastly, browser detection isn't a very good way to approach this, you're better
off using feature detection, and you can actually support Netscape 4, IE and
Netscape 7 all on a single page by choosing an alternative to changing the color
to the background color:
function removeWarningMsg() {
var div;
if (document.getElementById) { // IE5.5+, Opera 7, Mozilla
div = document.getElementById('Warning').style;
} else if (document.layers) { // NS4
div = document.layers['Warning'];
} else if (document.all) { // IE < 5.5
div = document.all('Warning');
}
if (div) {
div.visibility = 'hidden';
}
return true;
}
<span style="position:relative;" id="Warning">The warning</span>
"position:relative" is needed so the <span> shows up in the document.layers
collection in Netscape 4.
The comments are a comprehensive list of browsers that support each
method/collection, just an idea to show you what you might need to support the
browsers in your environment (for example, if you do not need to support IE <
5.5, I'd strongly recommend you use document.getElementById() over document.all.
--
| Grant Wagner <gw*****@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html