A标签包含Button在IE,360 等浏览器无法跳转的问题解决

<button><a href="http://www.baidu.com"></a></button>

 

有时为了使超链接拥有按钮的样式,就会使用 button 包含 a 标签的写法

这种写法在 IE浏览器或 360浏览器中会出现 button 点击无响应的情况,谷歌、火狐则可以识别

 

解决方法:
根本原因:有了 button 部分浏览器就会忽略掉 a 标签的 href 属性

所以将链接写入 button 的 onclick 的属性即可在任意浏览器中跳转

改写为:

<button class="button2" οnclick="window.open('http://www.baidu.com')">企业网上申报平台</button>

<button οnclick="window.open('http://www.baidu.com')"></button>

window.open('http://www.baidu.com'):新建窗口打开页面

window.location.href='http://www.baidu.com' : 当前窗口打开页面

-----------------------------

参考:

IE 下button 超链接失效的解决办法

换一个思路

<a class="按钮的样式" href=" 链接地址" >  按钮的名称 </a>

----------------------------------------

下面这种则在IE,火狐,google中都可以

<input type="button" οnclick="window.location.href='/jsp/manage/manage-context.jsp'" class="searchbut" value="返 回">
通过open方法,还可以设置打开页面的方式,如window.open(''index.html',_blank');

<a href = "index.html"><input type="button" value="a标签中如果有button" οnclick=window.open(''index.html',_blank')/ ></a>

初次遇到这种问题,纪念一下。

 


版权声明:本文为yhcad原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。