js在調用js函數的時候,函數名後不可以帶有圓括號,HTML標籤在調用js函數的時候須要有圓括號。javascript
<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>