473,698 Members | 2,521 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New to Javascript

I am new to javascript. I used the code below in Netscape 7.0 and in
IE 6.0. The Javascript portion does not render in Netscape , but it
does show in IE. Can someone explain why? Any helpful insight would
be appreciated.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlins="http://www.w3.org/1999/xhtml">
<head>
<title>Java Script Test</title>
</head>
<body bgcolor="#FFFFF ">
<h1> What is your problem
</h1>
<script language="javas cript"
type="text javascript">
<!-- Hide script from old browsers

document.write( "<h1> Today is </h1>")

// End hiding script from old broswers -->
</script>
</body>
</html>

Jul 23 '05 #1
7 1859
JSNewbie wrote on 29 mrt 2005 in comp.lang.javas cript:
I am new to javascript. I used the code below in Netscape 7.0 and in
IE 6.0. The Javascript portion does not render in Netscape , but it
does show in IE. Can someone explain why? Any helpful insight would
be appreciated.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlins="http://www.w3.org/1999/xhtml">
<head>
<title>Java Script Test</title>
</head>
<body bgcolor="#FFFFF ">
Better [get ]use[d to] CSS
White is default anyway
<h1> What is your problem
</h1>
<script language="javas cript"
language="javas cript" is depriciated, don't use
type="text javascript">
<!-- Hide script from old browsers
<!-- is depriciated for this use for more than 5 years, don't use

document.write( "<h1> Today is </h1>")
no problemo!!!

// End hiding script from old broswers -->
see above
</script>
</body>
</html>


Probably javascript switched off in the N7 broswer(?)

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2
Ivo
"Evertjan." wrote
JSNewbie wrote
<body bgcolor="#FFFFF ">


Better [get ]use[d to] CSS
White is default anyway


Not true. I know a machine where the default is gray, and another where the
default on white text on blue. So another tip: if specifying a
backgroundcolou r, you should explicitly set the foreground too.
<!-- Hide script from old browsers


<!-- is depriciated for this use for more than 5 years, don't use


That has been said before in this newsgroup, but I 'm wondering why even
sites like Google and Altavista still cloak comment their scripts like this.

--
Ivo
Jul 23 '05 #3
"Evertjan." <ex************ **@interxnl.net > writes:
JSNewbie wrote on 29 mrt 2005 in comp.lang.javas cript:
I am new to javascript. I used the code below in Netscape 7.0 and in
IE 6.0. The Javascript portion does not render in Netscape , but it
does show in IE. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlins="http://www.w3.org/1999/xhtml"> Should be:
<html xmlns="...
<head>
<title>Java Script Test</title>
</head>
<body bgcolor="#FFFFF ">


Better [get ]use[d to] CSS
White is default anyway


Agree on using CSS. Using XHTML with old, deprecated presentational tags
is mixing styles. It won't lead to anything good.

White is not the default background (not even in IE). The default is
the operating system's default window background, which on my computer
is slightly yellow. If you mean white, do use it.

However, what is written is not white. It needs another "F" to become
"#FFFFFF".
<h1> What is your problem
</h1>
<script language="javas cript"


language="javas cript" is depriciated, don't use


It's "deprecated ", but it means almost the same :)
type="text javascript">
This should be
type="text/javascript">
I think this is what is causing your problem. So, in total:

<script type="text/javascript">

is the way to start a script tag.
<!-- Hide script from old browsers


<!-- is depriciated for this use for more than 5 years, don't use


It's not deprecated as an HTML comment, but it is correct that it is
not needed inside a script element. The "old browsers" that it is
supposed to hide the script from were succeeded by the generation
of browsers starting with Netscape 2, around 1996.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
"Ivo" <no@thank.you > writes:

[not use "<!-- hide from old browsers"]
That has been said before in this newsgroup, but I 'm wondering why even
sites like Google and Altavista still cloak comment their scripts like this.


Because it's voodoo. You can add it, and it doesn't hurt you, so why
change anything that once worked.

The problem is that it can hurt you if you use XHTML. An XML processor
is free to remove comments before processing the rest, inside any
element, so it could remove your script contents.

Browsers probably won't do that, but if you use XHTML, it should be
because you expect to use other tools on it (browsers are fine with
HTML, IE doesn't even treat XHTML as XML, but only as malformed HTML).

Any browser that understands the script tag, even those that don't
understand its contents, will not need "<!--". That's pretty much any
browser since Netscape 2.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #5
Lasse Reichstein Nielsen wrote on 29 mrt 2005 in comp.lang.javas cript:
language="javas cript" is depriciated, don't use


It's "deprecated ", but it means almost the same :)


Your correction is apprecated, I pray, Lasse!

===========

M-W:
Main Entry: dep·re·cate
Etymology: Latin deprecatus,
past participle of deprecari to avert by prayer,
from de- + precari to pray

Main Entry: ap·pre·ci·ate
Etymology: Late Latin appretiatus,
past participle of appretiare,
from Latin ad- + pretium price
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #6
JSNewbie wrote:
I am new to javascript. I used the code below in Netscape 7.0 and in
IE 6.0. The Javascript portion does not render in Netscape , but it
does show in IE. Can someone explain why? Any helpful insight would
be appreciated.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlins="http://www.w3.org/1999/xhtml">
<head>
<title>Java Script Test</title>
</head>
<body bgcolor="#FFFFF ">
<h1> What is your problem
</h1>
<script language="javas cript"
type="text javascript">
<!-- Hide script from old browsers

document.write( "<h1> Today is </h1>")

// End hiding script from old broswers -->
</script>
</body>
</html>


The DOCTYPE is incomplete, and it should have "html" instead of "HTML".

The namespace property is spelled "xmlns", not "xmlins".

Forcing the body background color only is bad practice, because you
don't know what the user's default are. Either set all the colors or
leave them alone.

The "language" property of the "script" element is obsolete.

The MIME type for JavaScript is "text/javascript", not "text javascript".

Using <!-- ... --> is obsolete.

document.write does not work with XHTML (and isn't supposed to). Use the
DOM model.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Java Script Test</title>
</head>
<body>
<h1> What is your problem</h1>
<script type="text/javascript">
var body = document.getEle mentsByTagName( "body")[0];
var h1 = document.create Element("h1");
h1.appendChild (document.creat eTextNode (" Today is "));
body.appendChil d (h1);
</script>
</body>
</html>
--
John W. Kennedy
"Compact is becoming contract,
Man only earns and pays."
-- Charles Williams. "Bors to Elayne: On the King's Coins"
Jul 23 '05 #7
JSNewbie wrote:
I am new to javascript. I used the code below in Netscape 7.0 and in
IE 6.0. The Javascript portion does not render in Netscape , but it
does show in IE. Can someone explain why? Any helpful insight would
be appreciated.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlins="http://www.w3.org/1999/xhtml">
<head>
<title>Java Script Test</title>
</head>
<body bgcolor="#FFFFF ">
No such colour...
Mick

<h1> What is your problem
</h1>
<script language="javas cript"
type="text javascript">
<!-- Hide script from old browsers

document.write( "<h1> Today is </h1>")

// End hiding script from old broswers -->
</script>
</body>
</html>

Jul 23 '05 #8

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

Similar topics

0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8904
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.