2011-07-14 45 views
5

为什么不在身边的输入型A HREF提交在IE不能正常工作? (我能做些什么来解决这个问题)HREF提交

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen"> 
</head> 
<body> 
<a href="1.html"><input type="submit" class="button_active" value="1"></a> 
<a href="2.html"><input type="submit" class="button" value="2"></a> 
<a href="3.html"><input type="submit" class="button" value="3"></a> 
</body> 
</html> 

的style.css:

* { 
    margin: 0; 
    padding: 0; 
} 

/* CSS Buttons: http://www.web4site.de/css/css-buttons.php */ 
.button { 
    padding:0; 
    margin:0; 
    border:none; 
    font-size:14px; 
    background: url(../img/button.gif) no-repeat center; 
    color: #000000; 
    height:27px; 
    width:134px; 
    font-variant:small-caps; 
} 

.button:hover { 
    padding:0; 
    margin:0; 
    border:none; 
    font-size:14px; 
    background: url(../img/button.gif) no-repeat center; 
    color: #FF0000; 
    height:27px; 
    width:134px; 
    text-decoration:none; 
    font-variant:small-caps; 
} 

.button_active { 
    padding:0; 
    margin:0; 
    border:none; 
    font-size:14px; 
    background: url(../img/button.gif) no-repeat center; 
    color: #FF0000; 
    height:27px; 
    width:134px; 
    font-variant:small-caps; 
} 

这在Firefox罚款...

+0

你必须接受,html有其局限性 – Sotiris

回答

10

它不起作用,因为它不有道理(HTML 5明确禁止它)的意义不大。

要解决这个问题,请确定是否需要链接或提交按钮并使用您实际需要的任何一个(提示:您没有表单,因此提交按钮是无意义的)。

+0

它对我来说是合理的,因为我需要一个链接并使用输入类型来格式化它(与背景图像等)。 – Marc

+0

当你点击一个链接时,你会看到一个链接。当你点击一个提交按钮时,你提交一个表单。当你点击一个链接中的提交按钮时......同时按照链接提交表单?这两种都将浏览器发送到新的URI?这根本没有意义。 – Quentin

+2

这是你的问题。提交按钮是提交表单的一件事情,不是想让某个东西看起来像一个按钮。如果你想让东西看起来像一个按钮**使用CSS **。 – Quentin

0

将链接位置放在包装form标记的action=""中。

你的第一个环节是:

<form action="1.html"> 
    <input type="submit" class="button_active" value="1"> 
</form> 
+0

链接对于每种输入类型都不相同 - 。 - – Marc

+0

我假设他想提交输入数据,所以需要三种不同的形式: – Phil

11

你为什么要放锚内提交按钮?您要么尝试提交表单或转到其他页面。哪一个?

无论提交形式:

<input type="submit" class="button_active" value="1" /> 

或转到其他网页:

<input type="button" class="button_active" onclick="location.href='1.html';" /> 
+0

这一个工作正常。非常感谢:) – Marc

+0

没问题。随时接受这个答案。 ;) – Kon

0

我同意昆汀。对于你为什么要这样做没有意义。它是Semantic Web概念的一部分。你必须规划你的网站的对象,以便将来的整合/扩展。如果不遵循正确的用例,另一个Web应用程序或网站将无法与您的内容进行交互。

IE和Firefox是两个不同的野兽。 IE允许Firefox和其他标准浏览器拒绝许多事情。

如果您尝试在没有实际提交数据的情况下创建按钮,请使用DIV/CSS的组合。

0
<a href="1.html"><input type="text" class="button_active" value="1"></a> 
<a href="2.html"><input type="text" class="button" value="2"></a> 
<a href="3.html"><input type="text" class="button" value="3"></a> 

试试看。除非你真的需要坚持提交类型,那么我提供的应该可以工作。如果你要坚持提交,那么上面提到的一切都是正确的,这是没有意义的。