Click to See Complete Forum and Search --> : Checking version of Javascript


loxie28
03-26-2004, 02:19 PM
A company wrote some javascript to gather some data.
In the beginning of the script it looks like:

<SCRIPT LANGUAGE="Javascript"><!--
gVersion="1.0";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.1"><!--
gVersion="1.1";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.2"><!--
gVersion="1.2";
var RE={"%09":/\t/g, "%20":/ /g, "%23":/\#/g,"%26":/\&/g,"%2B":/\+/g,"%3F":/\?/g,"%5C":/\\/g};
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.3"><!--
gVersion="1.3";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.4"><!--
gVersion="1.4";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript1.5"><!--
gVersion="1.5";
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript"><!--

And then it goes into its function codes. It checks to see which version the person is using and assigns it to a variable.
Ok, question: If I have this code in an external .js file, just removing the <script ...></script> does not work in this case.

I tried adding <script ...><\/script> too. Nope.
I tried taking out all the <script ..... ></script> codes leaving just the variables too just to try that. Nope.

On the main HTML page, do I just use the generic <script language="javascript scr=" ....."></script> ?

steelersfan88
03-26-2004, 02:25 PM
you would have to use a sif't .js file for each one, For example:<script type="text/javascript"> var name_of_global_variable_modified_in_js_files; </script>
<SCRIPT LANGUAGE="Javascript" src="...js"></SCRIPT>
<SCRIPT LANGUAGE="Javascript1.1" src="...js"></SCRIPT>Note, there are better ways of doing this, gil's post may have that :)

gil davis
03-26-2004, 02:30 PM
The only browser that actually supports a language version like that is Netscape. Apparently, the author wrote something that relied on a feature in JS version 1.2, and was afraid someone using an old browser would stumble across his page. NS 4.7/4.8 supports JS 1.3 natively, so lower numbers were released prior to that.

The W3C depricated the "language=" attribute of the <SCRIPT> tag in favor of a "type=" attribute. If you are not specifically coding for old Netscape browsers, you should use the W3C reccommendations.
<SCRIPT TYPE="text/javascript" SRC="..."></SCRIPT>