一般来说,我是 JavaScript 和网页设计的新手,我不明白为什么这不起作用。
有两个问题。
1)我的页面标题不起作用,而是在浏览器标题栏中显示的是“ myHtml.html
”。只有当我宣布script
退出时,标题才有效。
2)我希望JavaScript生成的文本是蓝色的,有没有办法做到这一点?
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;
}