<b>Insert a number in either input field, and the number will be converted into either Celsius or Fahrenheit.</b> <br /> <form name="myform"> <input name="celsius" onkeyup="convert('C')"> degrees Celsius<br /> equals<br /> <input name="fahrenheit" onkeyup="convert('F')"> degrees Fahrenheit </form> <br /> Note that the <b>Math.round</b> method is used, so that the result will be returned as a whole number.
</body> </html>
转变字符为数字的例子
<html> <head>
<script type="text/javascript"> function toUnicode() { var str=document.myForm.myInput.value if (str!="") { unicode=str.charCodeAt(0) } document.myForm.unicode.value=unicode } </script> </head> <body>
<head> <script type="text/javascript"> function myTarget() { document.getElementById('myAnchor').target="_blank" } </script> </head>
<body> <a id="myAnchor" href="http://www.w3schools.com">Visit W3Schools</a> <form> <input type="button" onclick="myTarget()" value="Make the link open in a new window!"> </form> <p>Try the link before and after you have pressed the button!</p> </body>
</html>
使连接获得焦点和失去焦点
<html>
<head> <style type="text/Css"> a:active {color:blue} </style> <script type="text/javascript"> function getfocus()