[thelist] Javascript Validation Help - Comodo TrustLogo Display Script

Ron Dorman rwd at csi1st.net
Sun Feb 12 21:21:48 CST 2006


Matt Warden wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>
>
>Ron Dorman wrote:
>  
>
>>I modified the document.writeln as suggested and it did get rid of the 
>>'element not allowed here' error but threw another error due to and 
>>invalid attribute "scr not a valid element" or token name.
>>
>>I tried breaking it up into two scripts as follows:
>>
>><script type="text/javascript">
>>var cot_loc0=(window.location.protocol == "https:")? 
>>"https://secure.comodo.net/trustlogo/javascript/cot.js" :
>>"http://www.trustlogo.com/trustlogo/javascript/cot.js";
>></script>
>><script type="text/javascript" src="'+cot_loc0+'"></script>
>>
>>And it didn't generate and errors in the validator, but it no longer 
>>works to display the TrustLogo either. Either I have the syntax wrong or 
>>it isn't going to work as seperate scripts.
>>    
>>
>
>Yes, this won't work because the src attribute is not in the context of
>a script. You could try a hack like the following, but I don't know if
>it will work and if it does I probably wouldn't want to use it anyway:
>
><script type="..." src="javascript:cot_loc0"></script>
>
>Now, for the non-hackish shot-in-the-dark, inserting the script element
>via DOM:
>
><script type="text/javascript">
>var cot_loc0=(window.location.protocol == "https:")?
>"https://secure.comodo.net/trustlogo/javascript/cot.js" :
>"http://www.trustlogo.com/trustlogo/javascript/cot.js";
>
>if (document.getElementsByTagName && document.createElement) {
>    var head = (document.getElementsByTagName('head'))[0];
>    var script = document.createElement('script');
>    script.type = 'text/javascript';
>    script.src = cot_loc0;
>    head.appendChild(script);
>}
></script>
>
>I haven't tried this ebfore, but I've heard it thrown around on the JSAN list as a way to dynamically include dependencies, so it must work to some degree.
>
Thanks Matt, looks interesting. I assume it will place the appended 
script as the last element in the head.  I'll work with it and see what 
I can find out. Let you know.

Ron D.




More information about the thelist mailing list