Javascript run-time error when using a server certificate

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon

    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 removeWarningMs g()
    {
    if (isIE) {
    document.all.Wa rning.style.col or = "<%=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.w arning.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
  • Grant Wagner

    #2
    Re: Javascript run-time error when using a server certificate

    Simon wrote:
    [color=blue]
    > 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 removeWarningMs g()
    > {
    > if (isIE) {
    > document.all.Wa rning.style.col or = "<%=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.w arning.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[/color]

    View the source, is the page still producing a <span id="Warning">? If so, are
    you using document.all.Wa rning... or document.all.wa rning... (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 removeWarningMs g() {
    var div;
    if (document.getEl ementById) { // IE5.5+, Opera 7, Mozilla
    div = document.getEle mentById('Warni ng').style;
    } else if (document.layer s) { // NS4
    div = document.layers['Warning'];
    } else if (document.all) { // IE < 5.5
    div = document.all('W arning');
    }
    if (div) {
    div.visibility = 'hidden';
    }
    return true;
    }

    <span style="position :relative;" id="Warning">Th e warning</span>

    "position:relat ive" 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.getEle mentById() over document.all.

    --
    | Grant Wagner <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


    * 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


    Comment

    • Simon

      #3
      Re: Javascript run-time error when using a server certificate

      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!

      Comment

      Working...