Javascript question Javascript question - Talk of The Villages Florida

Javascript question

Closed Thread
Thread Tools
  #1  
Old 12-05-2013, 12:49 PM
Villag Villag is offline
Junior Member
Join Date: Jul 2012
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Default Javascript question

Need someone to look at this piece of HTML code and tell me why only a portion of my javascript code executes. The code is very small and fits into the "Hello World" complexity.
This happens in IE 11, Firefox 26.5, and Safari. Neither browser recognizes my javascript other then the Alert command.

Here's the code that works:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<title>Untitled Document</title>
</head>
<body>
<SCRIPT language="JavaScript">
<!--
alert("alert-aliens attacking");
document.write("alert-aliens attacking");
document.write("hello")
//-->
</script>
</body>
</html>

The Alert box comes up properly.

=========================================

When I run the following code;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Displaying Times and Dates</title>

</head>

<body>

<h1>Current Date and Time</h1>

<script type="text/javascript" >

alert("alert-aliens attacking");
document.write("alert-aliens attacking");

Now1 = New Date();
localtime1 = now1.Tostring();
utctime1 = now1.toGMTString();
document.write("<strong>Local Time:<strong> '
+ Localtime1 + '
");
document.write("<strong>UTC Time:</strong> " + utctime1);
</script>

</body>

</html>

Only the H1 displays. Nothing else works. Not even the Alert. Am I missing something?

Any assistance would be greatly appreciated.
Closed Thread


You are viewing a new design of the TOTV site. Click here to revert to the old version.

All times are GMT -5. The time now is 05:10 AM.

Help