Monday, 26 August 2013

Beginner javascript

Beginner javascript

I'm new to javascript and web design in general, and I don't understand
why this doesn't work. There are two problems. 1)The title of my page
doesn't work, and instead in the browser title bar what is displayed is
"myHtml.html". The title only works if i take the declaration of the
script out.
2)I want the text generated by javascript to be blue, is there a way to do
that?
HTML:
<!DOCTYPE html>
<html>
<head class = "Header">
<title>JavaScript Test</title>
<meta charset = "UTF-8">
<link rel = "stylesheet" type = "text/css" href = "myCSS.css" >
<script type= text/javascript src= myJavaScript.js></script>
</head>
<body class = "Body" onload = "testJavaScript()">
<p>
<noscript>
Your javascript is disabled
</noscript>
</p>
</body>
</html>
Javascript:
function testJavaScript(){
var message = "You Have Javascript!!";
document.writeln(message);
}
CSS:
@charset "UTF-8";
head.Header{
font-family:sans-serif;
color:green;
}
body.Body{
font-family:sans-serif;
color:blue;
}

No comments:

Post a Comment