2011-07-14 43 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> 

試試看。除非你真的需要堅持提交類型,那麼我提供的應該可以工作。如果你要堅持提交,那麼上面提到的一切都是正確的,這是沒有意義的。