在IE 11中,类型=“图像”的输入按钮不能与href一起使用

时间:2014-05-30 09:23:30

标签: javascript html asp.net-mvc-4

<a href="javascript:OpenRuleEditor('@Url.Action("AddRule", "AdvancedRuleSearch", new { mode = "add" })','AddNewRule','Add New Rule')" style="text-decoration: none; display:inline-block">                          
    <input name="Plus" type="image" src="~/GHAimages/129.png" id="btnAddRule" title="Add New Rule"/>
</a>

点击此按钮,它将打开一个新页面。 Button基本上是一个图像按钮(Iconic,可以帮助用户理解他们正在做什么)。在Firefox和Chrome中运行良好。但在IE 11中,它无法正常工作。当我从type =&#34; image&#34;更改其类型时键入=&#34;按钮&#34;,它开始工作,但它没有显示图像。

还尝试使用以下代码,将其放在标记内。

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

现在,图像显示在按钮上,按钮也在工作,页面也在打开,但在后面是调用它的窗口。

欢迎任何帮助..

2 个答案:

答案 0 :(得分:1)

您可以使用<img>标记而不是输入标记。

<a href="javascript:OpenRuleEditor('@Url.Action("AddRule", "AdvancedRuleSearch", new { mode = "add" })','AddNewRule','Add New Rule')" style="text-decoration: none; display:inline-block">
    <img src="~/GHAimages/129.png"></img>
</a>

另外,我认为您的路径中不需要代字号,请尝试将src="~/GHAimages/129.png"替换为src="/GHAimages/129.png"。我会在使用图片标签之前尝试这个。

答案 1 :(得分:0)

没有正当理由将<a href>标记包裹在input[type="image"]

您是否考虑过使用<img>