Welcome to WebmasterWorld Guest from 50.17.117.221

Forum Moderators: open

Message Too Old, No Replies

W3C Validator Error Help

using TYPE in a script tag for javascript 1.2

     
4:50 pm on Sep 11, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:May 4, 2002
posts:103
votes: 0


In using the w3C validator, I keep getting the error below. The Error Arrow, which I removed, was pointing at the ">"

What does "TYPE" Mean"? What is it looking for?

<script language="JavaScript"><!-- stuff
Error: required attribute "TYPE" not specified

Here is another one:

<script LANGUAGE="javascript1.2"><!-- stuff
Error: required attribute "TYPE" not specified

4:55 pm on Sept 11, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 10, 2001
posts:748
votes: 0


add type="text/javascript" into the script tag.

And you don't need the language attribute.

5:02 pm on Sept 11, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:May 4, 2002
posts:103
votes: 0


What would I do with

<script LANGUAGE="javascript1.2">

Does this become:

<script type="text/javascript">
OR
<script type="text/javascript1.2">

5:03 pm on Sept 11, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 10, 2001
posts:748
votes: 0


The first one.

<script type="text/javascript">

5:16 pm on Sept 11, 2002 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 27, 2001
posts:12166
votes: 51


> And you don't need the language attribute.

bobriggs, are you sure of that? The reason I ask is because that is 4 more bytes of code that I can eliminate from my pages and before I do so, I want to make sure.

5:23 pm on Sept 11, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 10, 2001
posts:748
votes: 0


[w3.org...]

Deprecated because there is no standard.

You might need a netscape 3 version for this to make any difference, but I think it would be backwards compatible anyway. (It would just ignore any script elements that it didn't know what to do with), but in that case, your script wouldn't work anyway.

[added]
If you do specify Javascript1.2 as a language attribute, this will keep NS3 from trying to execute it. There's a table on this page:
[developer.netscape.com...]

I don't think IE pays any attention to it. I also read somewhere else but can't verify it that if the src= attribute is used, the language attribute is ignored anyway.

6:20 pm on Sept 11, 2002 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 27, 2001
posts:12166
votes: 51


Thank you very much for the references bobriggs. The savings was 22 bytes per page from my <head> sections. We are currently micromanaging our code to trim out as much as we possibly can. Little tips like this add to the totals.

We've converted all of our external javascript references to this...

<script type="text/javascript" src="http://www.domain.com/javascript/file-name.js"></script>

We use absolute URL's for external file references. You can also use relative.

P.S. This is one of those times when the FP Find and Replace feature comes in handy. ;)

7:07 pm on Sept 11, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:June 7, 2002
posts:475
votes: 0


Note that specifying language="JavaScript1.2" makes Netscape 4 behave differently. In particular, the equality operator == returns false if the operands are of different data types (so 1=='1' returns false in NS4 with JavaScript1.2 specified, but otherwise it returns true), and some array and string handlers behave differently.

In other words, specifying JavaScript1.2 will cause NS4 to be even more incompatible than usual.

4:17 am on Sept 12, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 12, 2002
posts:885
votes: 0


Given that using the "Language" attribute on a style tag is deprecated, does anyone here know of a way to specify Javascript versions without using it? I have some scripts for a site I work on that almost certainly won't work in older versions of the language, but it would be just fine to leave them out. However, I'm writing to the XHTML Strict DTD, which means no "Language" attribute for me. Would something like type="text/ecmascript" both work and keep older browsers from trying to execute my code?
4:29 am on Sept 12, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 10, 2001
posts:748
votes: 0


No, the older browsers were looking for the language attribute. And I mean really old. Which JS version are you using?

I have some scripts for a site I work on that almost certainly won't work in older versions of the language

I know I'd like to support all possibilities, but when's the last time you saw a real Netscape 3 browser come by your site?

Unless you're trying to support Netscape 3 browsers, I wouldn't worry about it at all. It's really just a netscape thing anyway. Javascript1.2 started with the 4.0 browsers. If you're using 1.3 capabilities, it still should not matter unless you're worried about the early NN4 versions choking. But weren't Navigator 4.0-4.05 the beta numbers anyway?

5:39 am on Sept 12, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 12, 2002
posts:885
votes: 0


> when's the last time you saw a real Netscape 3 browser
> come by your site?

On my tiny little two-domain server with about 30 users and no reason for anyone else to show up? They all look like lying crack attempts. (and against the wrong operating system, no less)

The system I'm concerned about, however, has a significant portion of its users in Africa. I don't have access to the logs, but the people I work with/for assure me that not all the site's users have access to modern software and hardware.

I think that the compatability issue may well be as much DOM support as Javascript language features, but to be honest I know nothing about Javascript that I haven't learned from a couple of O'Reilly books in the past three weeks. I've always done everything server-side until my boss asked for DHTML menus. If you are interested, I can paste or mail the code I've written - it's three fairly short functions plus some style rules, and they work in Gecko and IE6.

As far as early NN4, I'm afraid I'm too young as a computer person to really recall. About that time, I was using Mosaic as a way to cut past the cruft on other peoples' sites and not paying much attention to NN, IE, and the browser wars. I also thought I'd never touch HTML until there were pleasant WYSIWYG editors for it, which is amusing in light of the fact that I now write everything in Emacs.