Jump to content

Comparison Operators parsed as HTML tags?


kingnutter

Recommended Posts

Hi Everyone,

 

I've typed this example from "Beginning Javascript" and it doesn't seem to work:

 

[pre]<html>

<head>

</head>

<body>

 

<script language=JavaScript type="text/javascript">

 

var degFahren = new Array(212, 32, -459.15);

var degCent = new Array();

var loopCounter;

 

for (loopCounter = 0; loopCounter <= 2; loopCounter++)

{

degCent[loopCounter] = 5/9 * (degFahren[loopCounter] - 32);

}

 

for (loopCounter = 2; loopCounter >= 0; loopCounter--)

{

document.write("Value " + loopCounter + " was " + degFahren[loopCounter] + " degrees Fahrenheit");

document.write(" which is " + " degCent[loopCounter] + " degrees centigrade<BR>");[pre][/pre]

}

 

</script>

</body>

</html>[/pre]

 

Nothing is mentioned in the online erratum. However this very similar program cut and pasted from the internet DOES work:

[pre]

<HTML> <HEAD> <TITLE>for example</TITLE> </HEAD>

<BODY>

<SCRIPT LANGUAGE=JavaScript>

 

var degFahren = new Array(212, 32, -459.15);

var degCent = new Array();

var loopCounter;

 

for (loopCounter = 0; loopCounter <= 2; loopCounter++) {

 

degCent[loopCounter] = 5/9 * (degFahren[loopCounter] - 32);

}

 

for (loopCounter = 2; loopCounter >= 0; loopCounter--) {

 

document.write("Value " + loopCounter + " was " +

degFahren[loopCounter] + " degrees Fahrenheit");

 

document.write(" which is " + degCent[loopCounter] +

" degrees centigrade<BR>");

}

 

</SCRIPT>

</BODY>

</HTML>[/pre]

 

 

I'm pretty sure it is because in the former the <= sign opens as an html tag, but I can't see what the difference between the two sets of codes is except a different case in the head of the latter and different script language definitions.

 

I am typing and testing the code in HyperEdit on a MacBook and also testing on Firefox with the same results.

 

Any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.