470,644 Members | 1,202 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,644 developers. It's quick & easy.

Javascript run-time error when using a server certificate

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
Jul 23 '05 #1
2 1991
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
Jul 23 '05 #2
Thanks for your reply Grant.
I can confirm that the span ID Warning is capitalised, so that
unfortunatley doesn't appear to be the problem.
Thanks for the advice on feature detection though, I will be giving that
a try.
Cheers Simon
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tony Gahlinger | last post: by
1 post views Thread by Jackson Yap | last post: by
13 posts views Thread by Alex Molochnikov | last post: by
9 posts views Thread by Pascal Vyncke | last post: by
6 posts views Thread by Melih Onvural | last post: by
7 posts views Thread by Rabel | last post: by
2 posts views Thread by goscottie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.