ASP scripting language query

P

Placek

Hello

Are the 3 script tags below all client-side javascript? If not, what are
they? If they are client-side javascript, why the different syntax (ie.
<SCRIPT>,
<SCRIPT LANGUAGE="JavaScript1.2">, <SCRIPT LANGUAGE="JavaScript">)?

Also, the syntax <%@ language=.... %> has been ommitted. Why is this, i
thought this was not allowed? Thanks

<SCRIPT>
function transform_url()
{
var suppress_host = false;

// an array to facilate searching of URL arguments
// callee wishes to preserve
var preserve = new Array;

// 'id' is a parameter we preserve by default
preserve['id'] = true;

// enumerate the array with arguments
for (i = 0; i < arguments.length; i++)
{
if (arguments == 'SuppressHost')
suppress_host = true;
else
preserve[arguments] = true;
}

// start constructing new URL
newurl = new String;
with (location)
{
if (suppress_host)
newurl += pathname.substr(1);
else
newurl += protocol + '//' + hostname + pathname;
}

// process the URL parameters
// string the leading '?' character if it exists
var parameters = (location.search.substr(0, 1) == '?') ?
location.search.substr(1) : location.search;
var params = parameters.split('&');
for (i = 0; i < params.length; i++)
{
nvpair = params.split('=');
if (nvpair.length >= 1) // check for valid name/value pair
{
if (preserve[nvpair[0]])
{
// append this parameter if callee
// specified it to be preserved
newurl += '_' + nvpair[0] + ((nvpair.length == 2) ? ('=' +
nvpair[1]) : '');
}
}
}

return newurl;
}

</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
var wtl_imgarray = new Array;
var wtl_ptr = 0;
function wtl_Tag6(wtl_TagID,wtl_SID,wtl_URL,wtl_Title,CONTENTGROUP)
{
function wtl_createImage(wtl_src)
{
if (document.images)
{
wtl_imgarray[wtl_ptr] = new Image;
wtl_imgarray[wtl_ptr].src = wtl_src;
wtl_ptr++;
}
}
function D8( d)
{
var fwd=1, seed= new Date('01/01/2000'), key=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var s= key.charAt( d.getFullYear()-2000)+key.charAt(
d.getMonth()+1)+key.charAt( d.getDate());
s+= key.charAt( d.getHours())+key.charAt( d.getMinutes())+key.charAt(
d.getSeconds());
while( seed.getDay()!=fwd) seed= new Date(seed.getTime() + 86400000);
var w= Math.floor( (d.getTime()-(seed.getTime()+86400000)) / 604800000 );
s+= key.charAt( (w-(w%16))/16 );
s+= key.charAt( w%16);
return s;
}
function A( B, C)
{
W+="&"+B+"="+escape(C);
}
var t = new Date();
var
W="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://statse.webtrendslive.com/S"
+ wtl_SID + "/button6.asp?tagver=" + wtl_TagVer + "&si=" + wtl_TagID + "&fw="
+ wtl_FWD;
A( "server", typeof(SERVER)== "string" ? SERVER : "");
A( "order", typeof(ORDER)== "string" ? ORDER : "");
A( "Group", typeof(CONTENTGROUP)== "string" ? CONTENTGROUP : "");
A( "invoice", typeof(INVOICE)== "string" ? INVOICE : "");
A( "cartview", typeof(CARTVIEW)== "string" ? CARTVIEW : "");
A( "cartadd", typeof(CARTADD)== "string" ? CARTADD : "");
A( "cartremove", typeof(CARTREMOVE)== "string" ? CARTREMOVE : "");
A( "checkout", typeof(CHECKOUT)== "string" ? CHECKOUT : "");
A( "cartbuy", typeof(CARTBUY)== "string" ? CARTBUY : "");
A( "adcampaign", typeof(ADCAMPAIGN)== "string" ? ADCAMPAIGN : "");
A( "tz", t.getTimezoneOffset());
A( "ch", t.getHours());
A( "cl", D8(t));
A( "ti", wtl_Title);
A( "url", wtl_URL);
A( "rf", window.document.referrer);
A( "js", "Yes");
A( "ul", navigator.appName=="Netscape" ? navigator.language :
navigator.userLanguage);
if(typeof(screen)=="object")
{
A( "sr", screen.width+"x"+screen.height);
A( "cd", screen.colorDepth);
A( "jo", navigator.javaEnabled() ? "Yes" : "No");
}
if( W.length>2048 && navigator.userAgent.indexOf('MSIE')>=0)
W= W.substring( 0, 2043)+"&tu=1";
wtl_createImage(W);
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
var wtl_TagVer = 6;
var wtl_FWD = 0;
var wtl_url = transform_url('vlnk','more','all');
var wtl_title = document.title;
var wtl_TagID = 139171;
var wtl_SID = "139171";
var ORDER= "";
var SERVER= "";
var CONTENTGROUP= "NS- Dataset, " +
transform_url('SuppressHost','vlnk','more','all');
var INVOICE= "";
var CARTVIEW= "";
var CARTADD= "";
var CARTREMOVE= "";
var CHECKOUT= "";
var CARTBUY= "";
var ADCAMPAIGN= "";
wtl_Tag6(wtl_TagID,wtl_SID,wtl_url,wtl_title,CONTENTGROUP);
//-->
</SCRIPT>
 
R

Ray Costanzo [MVP]

function transform_url()
...
</SCRIPT>

That's client-side script. Language is unspecified, which is a pretty bad
practice.

<SCRIPT LANGUAGE="JavaScript1.2">
That's specifiying the version of Javascript. If an old browser loads this,
it'll decide, "I don't know what 'Javascript1.2' is, so I'll just ignore
this."

<SCRIPT LANGUAGE="JavaScript">
That's just specifying Javascript without worrying about the version.
Unless you're writing stuff that's only available in certain versions of
Javascript, this is generally fine to use, although the more encouraged way
of doing it is:

<script type="text/javascript">
</script>

The ommission of <%@ Language... thing. Well, that has nothing to do with
the CLIENT-SIDE javascript you asked about. But, as far as ommitting that,
that's fine to do, as the page will use the default language that's defined
in IIS, which is VBScript in a default configuration.

In the future, feel free to trim away the four hundred million lines and a
half of javascript when you're asking only about the <script> tags.

Ray at work
 
P

Placek

Ray

Appreciate your response.....will chop away uneeded code next time. You
say ommitting <%@ language=.... %> defaults to vbscript.....does this mean
the first script in my post is client-side vbscript?

Thansk
 
B

Bob Barrows [MVP]

Placek said:
Ray

Appreciate your response.....will chop away uneeded code next time.
You say ommitting <%@ language=.... %> defaults to vbscript.....does
this mean the first script in my post is client-side vbscript?

No. The <%@ tag applies to server-side code. Leaving out that tag means that
the language in server-side code will be expected to be vbscript (the
default unless a configuration setting is changed at the web site level
using IIS Mgr). The default for client-side code is typically javascript
unless otherwise specified.

Server-side code is enclosed in <% ... %> tags or contained in a
<script runat=server> ... </script> block. Anything else is client-side
code.
 
D

Dave Anderson

Ray said:
<SCRIPT LANGUAGE="JavaScript1.2">
That's specifiying the version of Javascript. If an old browser
loads this, it'll decide, "I don't know what 'Javascript1.2' is, so
I'll just ignore this."


That's just specifying Javascript without worrying about the version.
Unless you're writing stuff that's only available in certain versions
of Javascript, this is generally fine to use, although the more
encouraged way of doing it is:

Interesting piece of trivia here, Ray.

When Netscape implemented Javascript 1.2, they introduced a nasty bug. The
equality operator would substitute for the assignment operator in
conditionals:

if (a=b) // treated like: if (a==b)

That bug was fixed in 1.3.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
R

Ray Costanzo [MVP]

Good Lord. You'd think that in testing a new version of a language, someone
may have used "if" once or twice. :]

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top