Javascript error

Discussion in 'JavaScript' started by Weirfire, Jan 23, 2009.

  1. #1
    Does anyone have any ideas why I'm getting a Javascript error on this page?

    http://www[dot]netcablesplus[dot]com

    I'm trying to display an SSL icon via a Javascript piece of code on another site. It appears to work on all my pages except the homepage. The Javascript code is called from just below the head tag and the call to the javascript function is done in the left column just below the paypal icon.
     
    Weirfire, Jan 23, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    microsoft script breaks here:
    {host=location.host; -> unsupported property or method.

    IE does support location.host so it must be a permissions error / ready state at time of calling

    You have:
    <script language="JavaScript" src="http://www.trustlogo.com/trustlogo/javascript/trustlogo.js" type="text/javascript"></script>
    ... which defines your functions

    And then some code:
    <a href="http://www.instantssl.com" id="comodoTL">SSL</a>
    <script type="text/javascript">TrustLogo("http://www.netcablesplus.com/images/tl_transp.gif", "SCAS", "none");</script>
    HTML:
    which embeds it.

    Thing about that is... the function being called does some nasty things like:

    - document.write (very much a bad idea and against best practices, slows down page display, can cock up DOM and needs to be waited out - the browser has to find out what will happen before it can continue as you can backmodify things it has already assessed)
    - inline javascript with event referencing: onmousedown="return tLKB(event,\''+tLX(tLiB(tLLC,tLa))+'\');" oncontextmenu="return tLLB(event);" - once again, very bad practice, especially when you consider IE - first of all, its not semantic. second of all, element inline event scripting (from DOM to JS) is known as the biggest and most common cause of cyclic references, which causes serious memory leaks. IE's garbage collectors are kind of unsure when (if ever) to release memory in such cases...

    my advice is:

    move the layer where that prints to the VERY BOTTOM of your SOURCE CODE. then use either CSS or JS to position it back up.

    ideally: look to do your own verification, copying what they tend to do.
     
    dimitar christoff, Jan 26, 2009 IP
    Weirfire likes this.
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Thanks for pointing me in the right direction. I checked the code over and over again and tried some of the hints you gave.

    However the problem was due to the fact that there was a line of code in the head setting the host as a different URL. This must have been conflicting with the JavaScript.
     
    Weirfire, Jan 27, 2009 IP