homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Javascript validation question

WebmasterWorld Senior Member 10+ Year Member

Msg#: 476 posted 12:33 pm on Jul 5, 2003 (gmt 0)

I use a remote service to gather statistics, and the HTML code they originally gave me was:

<script language="javascript" src="whatever">

That did not validate with transitional, so I added type=... to get:

<script type="text/javascript" language="javascript" src="whatever">

which validates fine in transitional but fails in strict.

The obvious solution is to go one step further and remove the offending language attribute. What worries me slightly is that the htmlhelp site says:

The required TYPE attribute of SCRIPT specifies the media type of the scripting language, e.g., text/javascript. However, most browsers only support the deprecated LANGUAGE attribute, which specifies the language name.

I suspect that much of htmlhelp is a little old, and I believe that I can safely discount that warning. The discussions on validating the Google AdSense code did not include any warnings about problems with browsers.

Still, I would be a lot happier if someone would confirm that most current browsers will work fine without the language attribute. If I fail to count five percent of my users it will be no big tragedy.



WebmasterWorld Senior Member 10+ Year Member

Msg#: 476 posted 2:57 pm on Jul 5, 2003 (gmt 0)

also try addign a </script> afterwards.

Sometimes validation is NOT everything, I'm afraid...



WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 476 posted 7:02 pm on Jul 5, 2003 (gmt 0)

Most browsers seem to do just fine without EITHER attribute, although this is not valid HTML. I stopped using the language attribute two years ago, and have seen zero report of trouble.

Even though, according to the W3C, there is no standard default scripting engine for HTML, Microsoft's developer's site [msdn.microsoft.com] says:

In Internet Explorer, the default scripting engine is JScript.

...so that takes care of a big chunk of visitors. Since Netscape developed javascript, I'm assuming that Netscape defaults to javascript

Also, here's a W3C Reference [w3.org] which offers a few extra insurance steps you can take:

Authors should specify the default scripting language for all scripts in a document by including the following META declaration in the HEAD: <META http-equiv="Content-Script-Type" content="type"> ...where "type" is a content type naming the scripting language. Examples of values include "text/tcl", "text/javascript", "text/vbscript".

In the absence of a META declaration, the default can be set by a "Content-Script-Type" HTTP header. Content-Script-Type: type ...where "type" is again a content type naming the scripting language.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved