JS之Location常见方法(二)herf页面跳转
JS中的点击按钮herf跳转
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>location对象</title> <script> window.onload = function(){ var bt = document.getElementById("bt"); bt.onclick = function(){ location.href = "https://www.baidu.com"; } } </script> </head> <body> <input type="button" value="百度" id="bt" /> </body> </html>