How to make href will work on button in IE8

2019-05-01 19:26发布

I want href will work on type="button"in IE8.

<a href="submit.php"><input type="button" value="Submit" class="button" /></a>

Other browser working fine but on IE8 the code above not working. How to fix it?

Update

<form action="submit.php" method="post"">
<input type="submit" value="Submit" class="button" />
</form>

I know this way can be done. But I want to know other ways how to make it work on IE8 without to have the <form></form>

3条回答
时光不老,我们不散
2楼-- · 2019-05-01 19:38

I used to be all happy that IE8 was not IE6. But seriously.

I'm using jQuery to patch up any button tag within an <a> link tag, inside conditional tags so it's just for old IEs.

<!--[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]-->
查看更多
干净又极端
3楼-- · 2019-05-01 19:43

onclick="window.location=this.parentNode.href;"/>

this.parentNode can refer to a tag so... it should work or test getAttribute even

查看更多
小情绪 Triste *
4楼-- · 2019-05-01 19:52

why not use

<form action="submit.php" method="get">
<input type="button" value="Submit" class="button" />
</form>

?

查看更多
登录 后发表回答