把用户带到一个新的地址

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function currLocation()
  5. {
  6. alert(window.location)
  7. }
  8. function newLocation()
  9. {
  10. window.location="/index.html"
  11. }
  12. </script>
  13. </head>
  14.  
  15. <body>
  16. <input type="button" onclick="currLocation()" value="显示当前的 URL">
  17. <input type="button" onclick="newLocation()" value="改变 URL">
  18. </body>
  19.  
  20. </html>