我希望href
能够在IE8中的type="button"
上运行。
<a href="submit.php"><input type="button" value="Submit" class="button" /></a>
其他浏览器工作正常,但在IE8上面的代码不起作用。如何解决?
更新
<form action="submit.php" method="post"">
<input type="submit" value="Submit" class="button" />
</form>
我知道这种方式可以做到。但我想了解其他方法如何让它在IE8上运行而不必拥有<form></form>
答案 0 :(得分:10)
的onclick = “window.location的= this.parentNode.href;”/&GT;
this.parentNode可以引用一个标签,所以...它应该工作或测试getAttribute甚至
答案 1 :(得分:1)
为什么不使用
<form action="submit.php" method="get">
<input type="button" value="Submit" class="button" />
</form>
答案 2 :(得分:0)
我曾经很高兴IE8不是IE6。但是说真的。
我正在使用jQuery修补<a>
链接标记内的任何按钮标记,在条件标记内,所以它只适用于旧的IE。
<!--[if lt IE 9]>
<script type="text/javascript">
// IE8 is the new IE6. Patch up http://stackoverflow.com/questions/2949910/how-to-make-href-will-work-on-button-in-ie8
$('button').click(function(){
document.location = $(this).parents('a').first().prop('href');
});
</script>
<![endif]-->