初学JS

 

<html>
<body>

<script type="text/javascript">
var txt="Hello World!"
document.writeln(txt.length);

var myDate=new Date();
document.writeln(myDate.getMonth());

var mycars=new Array();
mycars[0]="Saab";
mycars[1]="Volvo";
mycars[2]="BMW";
for(var i = 0; i < mycars.length; i++){
	document.writeln(mycars[i]);
}

document.writeln(Math.round(4.7));
document.writeln(Math.PI);

var browser=navigator.appName;
document.write("浏览器名称:"+ browser);
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
document.write("浏览器版本:"+ version);

</script>
<button type="button" >Click Me!</button>
</body>
</html>

你可能感兴趣的:(js)