html button按鈕的一些問題

2022-03-10 06:10:50 字數 2757 閱讀 9740

button 按鈕在不設定 type 屬性時,在不同的瀏覽器作用不一樣。舉個例子:

>button按鈕的一些問題

title

>

head

>

<

body

>

<

form

action

="result.php"

method

="post"

>

<

input

type

="text"

name

="txt"

placeholder

="隨便輸入點什麼吧!"

autocomplete

="off"

/>

<

button

>button點選提交

button

>

form

>

body

>

html

>

result.php:

<?php echo

$_post['txt'] ?>

我們發現,在 ie8 以上包括 ie8 點選按鈕可以正常提交表單,但是在 ie6 和 ie7 下面,點選按鈕沒有反應。

為什麼會有差異?因為 button 按鈕沒有設定 type 屬性,在不同的瀏覽器中解析 button 的 type 型別不盡相同。

通過 w3school 可以發現,我們需要始終為 button 按鈕規定 type 屬性。internet explorer(經測試是 ie6 和 ie7)的預設型別是 "button",而其他瀏覽器中(包括 w3c 規範)的預設值是 "submit"。具體內容點此了解

。最後我們修改下 demo:

>button按鈕的一些問題

title

>

head

>

<

body

>

<

form

action

="result.php"

method

="post"

>

<

input

type

="text"

name

="txt"

placeholder

="隨便輸入點什麼吧!"

autocomplete

="off"

/>

<

button

type

="button"

>button按鈕type為button

button

>

<

button

type

="submit"

>button按鈕type為submit

button

>

form

>

body

>

html

>

ps:

一些人,一些事,一些

我覺得這是國內it企業浮躁和傳統的官本位性質決定的,導致國內企業都本末倒置。要想改變命運,我覺得有以下出路 1.不做技術了,改做混混 混混的概念很廣泛的,比如銷售 經理 幹部 皮包公司之類其實都屬於這類。中國就是這樣,越浮越掙錢,只有混混才能發財。要不更進一步,做流氓,廣義的流氓,也很不錯。2.專心...

關於RemoteView 的一些字型的一些問題

最近在做乙個 在notification 新增 天氣通知的小部分 發現困擾在 如何給 remoteview 中的字型 作修改 大家都知道 textview 設定字型 在xml 中 可以 設定 3種 而其他字型的設定 需要通過 typeface 去設定 具體 將字型放置在asset 資料夾中 type...

iPhone UITableVIew 的一些理解

uitableview 用的不少,其重用機制還是有點迷惑。之前有用過sdwebimage和 結合該demo,做個小總結 2 uitableview可以響應uiscrollview 的delegate,因為uitableview中就有乙個scrollview 得先宣告 inte ce rootview...