473,387 Members | 1,745 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,387 software developers and data experts.

Why do this? <SCRIPT TYPE="text/javascript"

Hi;

I've being going through some legacy code on an old JSP site I have
been patching. I noticed that when I save the JSP down to my PC as an
HTML file I get this javascript error in IE 6 ( not in the latest
Firefox ):

"invalid character"

The problem traces back to this line of code:

<SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>

It goes away if I remove the "text/".

I have never seen a script tag with "TYPE" or "text/javascript"
used. Only "language = "javascript""

What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?

Thanks in advance



Jun 27 '08 #1
9 4344
Steve wrote:
I've being going through some legacy code on an old JSP site I have
been patching. I noticed that when I save the JSP down to my PC as an
HTML file I get this javascript error in IE 6 ( not in the latest
Firefox ):

"invalid character"

The problem traces back to this line of code:

<SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>
Chances are a resource with the relative URI abc/jsp/blah.js simply does not
exist (because you have missed downloading it to the appropriate location in
the local filesystem), in which case the error message generated by the user
agent or the Web server does not constitute a syntactically correct program.
It goes away if I remove the "text/".
Probably because the script is never loaded then.
I have never seen a script tag with "TYPE" or "text/javascript" used.
Then you have seen either only Valid HTML 3.2, where the `script' _element_
has no attributes, or a lot of invalid HTML code.
Only "language = "javascript""
But using that ranges from being deprecated to invalid nowadays.
What is <SCRIPT TYPE="text/javascript" used for?
To include code written in and for client-side ECMAScript implementations.
Is it necessary?
The `type' attribute of the `script' element is required, and a MIME media
type is required as its value, since HTML 4.0:

http://www.w3.org/TR/REC-html40/inte...ml#edef-SCRIPT
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #2
Steve wrote:
I've being going through some legacy code on an old JSP
site I have been patching. I noticed that when I save
the JSP down to my PC as an HTML file I get this
javascript error in IE 6 ( not in the latest
Firefox ):

"invalid character"

The problem traces back to this line of code:

<SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>
That error usually means that the SRC's URL does not refer to an
existing resource, and the resulting 404 error page is HTML which when
interpreted as javascript source code will produce one form of syntax
error or another.
It goes away if I remove the "text/".
Yes, you have then prevented the browser from recognising the type of
script and so it is not passing it into its javascript interpreter and
so not finding the HTML that it is receiving erroneous when interpreted
as javascript.
I have never seen a script tag with "TYPE" or "text/javascript"
used.
Then you had best leave web development to someone with a little more
relevant experience.
Only "language = "javascript""
The language attribute of SCRIPT elements is deprecated in HTML 4 and
not usable with strict (x)HTML DTDs.
What is <SCRIPT TYPE="text/javascript" used for?
The type attribute is required in valid HTML and is used to declare the
type of script language used.
Is it necessary?
For valid mark-up it is required, in a purely practical sense it is not
necessary. Most browsers will default to assuming javascript is the type
of script language to use unless told something else, and most browsers
can cope with defective/non-valid (a.k.a. 'tag soup') HTML mark-up to
some degree or another. On the other hand, using mark-up that it at
minimum structurally valid can avoid issues when attempting to script
the resulting DOM, and having formally valid mark-up is one way of
guaranteeing that the mark-up is structurally valid.

Richard.

Jun 27 '08 #3
Thomas 'PointedEars' Lahn wrote:
Steve wrote:
>Only "language = "javascript""
But using that ranges from being deprecated to invalid nowadays.
PointedEars
Which browser(s) treat language="javascript" as invalid?
Jun 27 '08 #4
Steve wrote:
I have never seen a script tag with "TYPE" or "text/javascript"
used. Only "language = "javascript""
That's the form I always use. In Dreamweaver, if you type <script and
then a space, several choices come up and one is "type". Under that
there are a few choices, the first of which is "text/javascript".
>
What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?

Thanks in advance


Jun 27 '08 #5
On May 6, 1:35 pm, Steve <tinker...@gmail.comwrote:
Hi;

I've being going through some legacy code on an old JSP site I have
been patching. I noticed that when I save the JSP down to my PC as an
HTML file I get this javascript error in IE 6 ( not in the latest
Firefox ):

"invalid character"

The problem traces back to this line of code:

<SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>

It goes away if I remove the "text/".
That is strange. I've never had a problem. Is the "blah.js" file in
some strange character encoding?

I have never seen a script tag with "TYPE" or "text/javascript"
used. Only "language = "javascript""

What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?
This is a bit of a tricky area. In mid 2006(?) the official type was
approved as "application/javascript" however everyone had been using
"text/javascript" and so there will be a transition period before
using "application/javascript" is the norm.

The type attribute is required by the HTML spec

http://www.w3.org/TR/REC-html40/inte....html#h-18.2.1

so if you want your page to validate as HTML

http://validator.w3.org/

you will need to include the type attribute.

-----------

Just in case you are new to validation, before you have a chance to
get excited about XHTML for the general web

http://www.thewebcreator.net/2007/04...tead-of-xhtml/
http://www.webdevout.net/articles/beware-of-xhtml

Also HTML 5 is almost surely the future of the web. XHTML just didn't
have a good chance with how strict it is and without support in
Internet Explorer, I guess.

Peter
Jun 27 '08 #6
On May 7, 8:02 am, Stevo <n...@mail.invalidwrote:
Thomas 'PointedEars' Lahn wrote:
Steve wrote:
Only "language = "javascript""
But using that ranges from being deprecated to invalid nowadays.
PointedEars

Which browser(s) treat language="javascript" as invalid?
Thomas isn't referring to browsers, he's talking about
specifications. See Richard Cornford's reply to the OP.
--
Rob
Jun 27 '08 #7
Peter Michaux wrote:
On May 6, 1:35 pm, Steve <tinker...@gmail.comwrote:
>I've being going through some legacy code on an old JSP site I have
been patching. I noticed that when I save the JSP down to my PC as an
HTML file I get this javascript error in IE 6 ( not in the latest
Firefox ):

"invalid character"

The problem traces back to this line of code:

<SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>

It goes away if I remove the "text/".

That is strange. I've never had a problem. Is the "blah.js" file in
some strange character encoding?
That would not matter, unless we are talking a misconfigured local Web
server here which appears to be unlikely from the OP's description.
Instead, it is very likely that the OP only stored the JSP and not the
script, or they did not store it in the path where it belongs according to
the above `script' element.
>What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?

This is a bit of a tricky area. In mid 2006(?) the official type was
approved as "application/javascript" however everyone had been using
"text/javascript" and so there will be a transition period before
using "application/javascript" is the norm.
Will you please get that right eventually? RFC4329 cause the registration
of four media types for ECMAScript implementations, two especially for
javascript:

http://pointedears.de/scripts/test/mime-types/
Also HTML 5 is almost surely the future of the web.
Wishful thinking.
XHTML just didn't have a good chance with how strict it is and without support in
Internet Explorer, I guess.
Quite the contrary. XHTML is continuously gaining speed on the Web despite
that because people use XML-compliant tools to generate it and serve it to
IE (and, unfortunately XHTML-compliant UA as well) as text/html instead.
While that practice surely is debatable, it is a development reality.

For example, we are mainly developing Plone-based Web sites (a decision made
by one of my predecessors that I have to live with). A Zope Page Template
(ZPT) that is required for efficient templating there (one wants to avoid
DTML for non-trivial templates) is an XML application, and if HTML code is
to be included it has to be XHTML or the template simply won't compile. So
I have to serve Appendix-C-compatible XHTML 1.0 Transitional as text/html
for those sites, knowing that I am relying on erroneous error-correction on
the part of user agents.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #8
Thomas 'PointedEars' Lahn a écrit :
For example, we are mainly developing Plone-based Web sites (a decision made
by one of my predecessors that I have to live with). A Zope Page Template
Obviously, it can't be your responsability to have choosen such a thing.

So obvious.
(ZPT) that is required for efficient templating there (one wants to avoid
DTML for non-trivial templates) is an XML application, and if HTML code is
to be included it has to be XHTML or the template simply won't compile. So
I have to serve Appendix-C-compatible XHTML 1.0 Transitional as text/html
for those sites, knowing that I am relying on erroneous error-correction on
the part of user agents.
Muahahaha, shoot yourself in the foot (bad tools, change tools). And you
dare being a dick when other ppl are saying they do the same as you do.

Pathetic

--
laurent
Jun 27 '08 #9
On May 7, 3:19 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Peter Michaux wrote:
Also HTML 5 is almost surely the future of the web.

Wishful thinking.
I'm not sure why you need to be so cryptic so frequently and require
me asking you to complete your explaination. Anyway...what do you mean
by "wishful thinking"? Do you mean you think XHTML is the future or
HTML 4.1 will remain the standard or that tag soup is the only way
etc.

For example, we are mainly developing Plone-based Web sites (a decision made
by one of my predecessors that I have to live with). A Zope Page Template
(ZPT) that is required for efficient templating there (one wants to avoid
DTML for non-trivial templates) is an XML application, and if HTML code is
to be included it has to be XHTML or the template simply won't compile. So
I have to serve Appendix-C-compatible XHTML 1.0 Transitional as text/html
for those sites, knowing that I am relying on erroneous error-correction on
the part of user agents.
Hard to believe you rely on user-agent forgiveness based on all the
elitist posturing you do frequently. It's good you will admit it,
however, rather than fake purity.

Peter
Jun 27 '08 #10

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

Similar topics

4
by: j.t.w | last post by:
Hi All. I'm having a problem with my Date of Birth textbox. When I open the ..htm file, the "DoB" textbox is flat with a border. All of my other textboxes are sunken and are yellow. When I...
9
by: Arash Dejkam | last post by:
Hi All, Is it possible to write on an <OBJECT type="text/html"> using document.write() from within the html containing that tag the way we write on a popup window? I couldn't do that after a lot...
9
by: David D. | last post by:
Does the file extension matter when including a JavaScript file in an HTML page? Normally, one would include a JavaScript file in an HTML page using <script src="foo.JS" type="text/javascript">...
3
by: Silmar | last post by:
Hi! In my form I have table which cells contain input objects of type="text" which initially are disabled. I would like to activate them by clicking on them. However because input object does...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
2
by: alxasa | last post by:
Hello, I am hoping someone can help me with this. I need a javascript function, which sits inside a <input type="text" name="firstname"> line of code. Now, if someone starts typing fine, but when...
3
by: joe | last post by:
Is it OK to have multiple: <script type="text/javascript" src="funcs1.js"></script> <script type="text/javascript" src="funcs2.js"></script> <script type="text/javascript"...
2
by: Warren Tang | last post by:
Hello, everyone Can I make a <input type="text"tag transparent? I mean I can see through it and see the background of its container. Regards Warren
33
by: Sunny | last post by:
Hi, Sometime, when your script is too big, IE Gives you a warning "Stop Running This Script" A script on this page is causing Internet Explorer to run slowly. Does anyone knows, How to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.