给按钮添加超链接

在原窗口跳转到新网址

<button onclick="window.location.href='http://www.baidu.com'">链接</button>

打开新窗口跳转到新网址

<button onclick="window.open('http://www.baidu.com')">链接</button>

这两个方法不一样,之前有人的代码都是()其实是错的

注意:第一个是用赋值的方法,是用的=号,第二个是传参的方法。
 

猜你喜欢

转载自blog.csdn.net/zhaofeiweb/article/details/83109872