js 中实现页面跳转的方法(window.location和window.open的区别)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>onchange的使用方法</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> <script type="text/javascript"> function old_page() { window.location = "http://www.baidu.com" } function replace() { window.location.replace("http://www.baidu.com") } function new_page() { window.open("http://www.baidu.com") } </script> </head> <body> <input type="button" onclick="new_page()" value="new_page"/> <br /> <input type="button" onclick="old_page()" value="old_page"/> <br /> <input type="button" onclick="replace()" value="replace"/> <br /> <select onchange="window.location=this.value"> <option value="http://www.baidu.com">百度</option> <option value="http://www.sina.com">新浪</option> </select> <br /> <select onchange="window.open(this.value)"> <option value="http://www.baidu.com">百度</option> <option value="http://www.sina.com">新浪</option> </select> <br /> <select onchange="window.location.replace(this.value)"> <option value="http://www.baidu.com">百度</option> <option value="http://www.sina.com">新浪</option> </select> </body> </html>