js在调用js函数的时候,函数名后不能够带有圆括号,HTML标签在调用js函数的时候需要有圆括号。
<html>
<head>
<title>My First Script</title>
<style type="text/css">
.highlight{color:red;}
</style>
<script type="text/javascript">
function showBrowserType(){
document.getElementById("readout").innerHTML="<span class='highlight'>Your Browser Says it is:"+navigator.userAgent+"</span>.<hr />";
}
//window.onload=showBrowserType;
</script>
</head>
<body>
<h1>Let's Script...</h1>
<hr />
<div id="readout"></div>
<input type="button" id="btn" value="click" onclick="showBrowserType()"/>
</body>
</html>