473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Javascript 1.3

Can anyone tell me which browsers implement Javascript 1.3?
Specifically, which browsers will handle the identity operator (===)
correctly? I ask because jslint suggests using it, but I don't want
to get too cutting edge.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #1
16 1695


Christopher Benson-Manica wrote:
Can anyone tell me which browsers implement Javascript 1.3?
Specifically, which browsers will handle the identity operator (===)
correctly? I ask because jslint suggests using it, but I don't want
to get too cutting edge.


Netscape browsers support Javascript 1.3 and === since 4.06 and later
version, IE (at least on Windows) should have support for === since IE4
but that is only from my recollection, the JScript docs don't tell that
in detail.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Martin Honnen <ma*******@yahoo.de> spoke thus:
Netscape browsers support Javascript 1.3 and === since 4.06 and later
version, IE (at least on Windows) should have support for === since IE4
but that is only from my recollection, the JScript docs don't tell that
in detail.


I see. Another question: If I explicitly specify JS1.3 like so:

<script type=\"text/javascript1.3\">

(well, I suppose that's how it's done...), and the browser does not
implement 1.3, what will the browser do?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #3


Christopher Benson-Manica wrote:

Another question: If I explicitly specify JS1.3 like so:

<script type=\"text/javascript1.3\">

(well, I suppose that's how it's done...), and the browser does not
implement 1.3, what will the browser do?


If you want to use a version then you would need the language attribute e.g.
<script language="JavaScript1.3">
older browsers like Netscape 4.00-4.05 or Netscape 3 then ignore the
script element's content.

But nowadays you shouldn't need to use <script language>, simply use
<script type="text/javascript">
the need for versioning your script elements is gone, if someone is
still around with Netscape 4 then hardly with 4.00-4.05 and with IE5 and
later there shouldn't be any problems either

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #4
Martin Honnen wrote:
<snip>
... , IE (at least on Windows) should have support for === since
IE4 but that is only from my recollection, the JScript docs don't
tell that in detail.


I believe that it was IE 5.0 that was the first IE browser to be
released with a JScript version that supported - === -, but JScript on
windows is independent of the browsers so even an IE 4 user may have a
later JScript version installed (if they have updated WSH, for example)
and IE 4 would use that version to execute scripts.

Richard.
Jul 23 '05 #5
"Martin Honnen" <ma*******@yahoo.de> wrote:
If you want to use a version then you would need the language attribute e.g. <script language="JavaScript1.3">
older browsers like Netscape 4.00-4.05 or Netscape 3 then ignore the
script element's content.
But nowadays you shouldn't need to use <script language>, simply use
<script type="text/javascript">


This is often said, but this is a good example - if a person wants to use
===, and doesn't specify the language="Javasscript1.2" then how can they
make sure older browsers don't execute the code block?

The typical answer is "test for features" but you can't test for new
operators like you can for properties of objects. If you use try/catch, then
that breaks in older browsers.

How can a developer use === and not break older browsers?

--
Matt Kruse
Javascript Toolbox: http://www.mattkruse.com/javascript/
Jul 23 '05 #6


Matt Kruse wrote:
"Martin Honnen" <ma*******@yahoo.de> wrote:
If you want to use a version then you would need the language attribute
e.g.
<script language="JavaScript1.3">
older browsers like Netscape 4.00-4.05 or Netscape 3 then ignore the
script element's content.
But nowadays you shouldn't need to use <script language>, simply use
<script type="text/javascript">

This is often said, but this is a good example - if a person wants to use
===, and doesn't specify the language="Javasscript1.2" then how can they
make sure older browsers don't execute the code block?


1.2 doesn't help as === is 1.3 but maybe that is a typo.

The typical answer is "test for features" but you can't test for new
operators like you can for properties of objects. If you use try/catch, then
that breaks in older browsers.

How can a developer use === and not break older browsers?


One way I see is using several script blocks and probably external
script files with different versions (e.g. one using === and one using
==) in the following way:

<script type="text/javascript">
var idTest = false;
</script>
<script type="text/javascript">
idTest = 1 === 1;
</script>
<script type="text/javascript">
if (idTest) {
var src = 'fileId.js';
}
else {
var src = 'file.js';
}
document.write('<script type="text/javascript" src="' + src +
'"><\/script>');
</script>

With older browsers the second script block should yield a syntax error
and therefore in the third script block the variable idTest is false so
you can write out a reference to a file.

A similar scheme should work for try/catch e.g.

<html>
<head>
<title>Checking for try/catch</title>
<script type="text/javascript">
var tcTest = false;
</script>
<script type="text/javascript">
try {
tcTest = true;
}
catch (e) {

}
</script>
<script type="text/javascript">
if (tcTest) {
var src = 'test20040416tc.js';
}
else {
var src = 'test20040416.js';
}
document.write('<script type="text/javascript" src="' + src +
'"><\/script>');
</script>
</head>
<body>
</body>
</html>

with test20040416tc.js being for test cases just

alert('Could use try/catch here.');

and the other file then

alert('Can\'t use try/catch here.');

That way if you try the test case with Netscape 4 which doesn't support
try/catch no error is generated and you can load a script file which
doesn't use try/catch.
But as said I think you can safely ignore browsers not supporting ===,
you can't forever try to make sure your script doesn't break with
antiquated browsers.
As for try/catch if you still think you have to deal with Netscape 4
users then you have the choice to avoid try/catch totally or use an
approach as outlined above. There are also other ways to use try/catch
in certain browsers safely (e.g. IE with conditional comments, Netscape
6/7 respectively Mozilla with <script type="text/javascript;
version=1.5">) if you are only scripting features for those browser like
XMLHttpRequest.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #7
On Fri, 16 Apr 2004 11:15:18 -0500, Matt Kruse <ne********@mattkruse.com>
wrote:

[snip]
How can a developer use === and not break older browsers?


You probably can't, but you can avoid it altogether.

function isExact( a, b ) {
return(( typeof a == typeof b ) && ( a == b ));
}

This is results in exactly the same algorithm, just less efficient (the
typeof comparison is a string comparison, rather than a direct type check).

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #8
"Michael Winter" <M.******@blueyonder.co.invalid> wrote:
How can a developer use === and not break older browsers?

You probably can't, but you can avoid it altogether.


Which is why I think it's ridiculous that type="text/javascript" is supposed
to replace language="Javascript".

Same think with try/catch, or any other keyword additions and language
changes in different versions.
If you're developing for an internet audience, you can't use any of these
new features, because there is no way (that I've found) to degrade nicely,
without relying on language="Javascript1.3", etc.

Causing a syntax error while determining whether or not an operator is
supported (as another poster suggested) isn't really a good solution, IMO.

--
Matt Kruse
Javascript Toolbox: http://www.mattkruse.com/javascript/


Jul 23 '05 #9
"Matt Kruse" <ne********@mattkruse.com> writes:
Same think with try/catch, or any other keyword additions and language
changes in different versions.
If you're developing for an internet audience, you can't use any of these
new features, because there is no way (that I've found) to degrade nicely,
without relying on language="Javascript1.3", etc.


The problem with the language attribute is that not all browser honor it,
and that later versions are not necessarily compatible with earlier code.
Example of the latter:
<script language="Javascript1.2">
var a=1,b=2;
if (a=b) {alert("Foo!");}
</script>

This should not alert "Foo!", but in browsers that support Javascript
1.3 and *not* 1.2, it will (one example is IE 6).
That is, supporting Javascript1.3 does not mean that one supports 1.2!

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #10
JRS: In article <c5*******************@news.demon.co.uk>, seen in
news:comp.lang.javascript, Richard Cornford
<Ri*****@litotes.demon.co.uk> posted at Fri, 16 Apr 2004 15:30:57 :
Martin Honnen wrote:
<snip>
... , IE (at least on Windows) should have support for === since
IE4 but that is only from my recollection, the JScript docs don't
tell that in detail.


I believe that it was IE 5.0 that was the first IE browser to be
released with a JScript version that supported - === -, but JScript on
windows is independent of the browsers so even an IE 4 user may have a
later JScript version installed (if they have updated WSH, for example)
and IE 4 would use that version to execute scripts.


The initial UK release of Win98 came with an MSIE4 that accepts all but
the now commented-out line of
var A, B
A=B
A==B
A===B
// A====B

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.
Jul 23 '05 #11
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote:
<script language="Javascript1.2">
var a=1,b=2;
if (a=b) {alert("Foo!");}
</script>
This should not alert "Foo!", but in browsers that support Javascript
1.3 and *not* 1.2, it will (one example is IE 6).
I'm not sure what you mean, here. It _should_ alert Foo, from what I
understand. a=b evaluates to 2 as an expression, which is true, which makes
the alert fire. If b is 0, then it does not fire. The exception is in
Netscape browsers, which treated this situation differently when explicitly
specifying "Javascript1.2" as the language.
That is, supporting Javascript1.3 does not mean that one supports 1.2!


It certainly should. I think the example you're pointing out is an exception
in Netscape browsers.
Someone feel free to correct me :)

--
Matt Kruse
Javascript Toolbox: http://www.mattkruse.com/javascript/
Jul 23 '05 #12
"Matt Kruse" <ne********@mattkruse.com> writes:
I'm not sure what you mean, here. It _should_ alert Foo, from what I
understand. a=b evaluates to 2 as an expression, which is true, which makes
the alert fire. If b is 0, then it does not fire. The exception is in
Netscape browsers, which treated this situation differently when explicitly
specifying "Javascript1.2" as the language.
Yes, because they actually implement Javascript1.2. In JS1.2, "=" in
if-statments was treated as a comparison. In JS1.3 (and 1.1) it wasn't.

If you request JS1.3, you don't want browsers that doesn't support it
(but only, e.g., 1.2) to run the script. Running an 1.3 script with
an 1.2 interpreter will give wrong results.

My point is that running an 1.2 script with an 1.3 interpreter will
*also* give the wrong result. However, no browser supporting only 1.3
scripts will skip script with language="Javascript1.2".
That is, supporting Javascript1.3 does not mean that one supports 1.2!


It certainly should.


Only if 1.3 is a pure extension of 1.2. It isn't.
I think the example you're pointing out is an exception
in Netscape browsers.


That exception would be recognizing and respecting the language
attribute.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #13
Dr John Stockton wrote:
<snip>
... (if they have updated WSH, for example) and
IE 4 would use that version to execute scripts.


The initial UK release of Win98 came with an MSIE4 that accepts all
but the now commented-out line of
var A, B
A=B
A==B
A===B
// A====B


Out of curiosity, what sort of output do you get from the following:-

var out = 'No ScriptEngine Funciton';
if(window.ScriptEngine){
out = ScriptEngine();
if(window.ScriptEngineMajorVersion){
out += ' '+ScriptEngineMajorVersion();
}
if(window.ScriptEngineMinorVersion){
out += '.'+ScriptEngineMinorVersion();
}
if(window.ScriptEngineBuildVersion){
out += '.'+ScriptEngineBuildVersion();
}
}
alert(out);

Richard.
Jul 23 '05 #14
"Richard Cornford" <Ri*****@litotes.demon.co.uk> writes:
The initial UK release of Win98 came with an MSIE4 that accepts all
but the now commented-out line of
var A, B
A=B
A==B
A===B
Out of curiosity, what sort of output do you get from the following:-


I just tested a stand-alone version of IE 4 that accepts ===, and it
reports: JScript 3.1.3510

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #15
On Fri, 16 Apr 2004 13:07:38 -0500, "Matt Kruse"
<ne********@mattkruse.com> wrote:
Same think with try/catch, or any other keyword additions and language
changes in different versions.
If you're developing for an internet audience, you can't use any of these
new features, because there is no way (that I've found) to degrade nicely,
without relying on language="Javascript1.3", etc.
but that's never been a reliable solution anyway, it was ignored by
too many of the old browsers - the ones we need to protect.
Causing a syntax error while determining whether or not an operator is
supported (as another poster suggested) isn't really a good solution, IMO.


Absolutely, that's definately unacceptable, I wouldn't use ===, it's
one of things I disagree with jslint on.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 23 '05 #16
JRS: In article <c5*******************@news.demon.co.uk>, seen in
news:comp.lang.javascript, Richard Cornford
<Ri*****@litotes.demon.co.uk> posted at Sat, 17 Apr 2004 14:18:30 :
Out of curiosity, what sort of output do you get from the following:-

var out = 'No ScriptEngine Funciton';
if(window.ScriptEngine){
out = ScriptEngine();
if(window.ScriptEngineMajorVersion){
out += ' '+ScriptEngineMajorVersion();
}
if(window.ScriptEngineMinorVersion){
out += '.'+ScriptEngineMinorVersion();
}
if(window.ScriptEngineBuildVersion){
out += '.'+ScriptEngineBuildVersion();
}
}
alert(out);


It's easier for me without the alert - that is equivalent to

out = "JScript 3.1.2124"

on my system.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.