HTML button 標(biāo)簽參考手冊(cè)HTML <button> 標(biāo)簽

當(dāng)您使用 formaction 屬性時(shí),表單的提交地址將使用屬性本身的值,而不是<form>標(biāo)簽的 action 屬性的值,請(qǐng)參考下述示例: 

實(shí)例

帶有兩個(gè)提交按鈕的表單(帶有不同的 action),第一個(gè)提交按鈕將表單數(shù)據(jù)提交到 "demo_form.html", 第二個(gè)提交按鈕將表單數(shù)據(jù)提交到 "demo_admin.html":

<form action="demo_form.html" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit">提交</button><br>
<button type="submit" formaction="demo_admin.html">提交</button>
</form>

嘗試一下 ?

瀏覽器支持

Internet Explorer Firefox Opera Google Chrome Safari

Internet Explorer 10, Firefox, Opera, Chrome, 和 Safari 支持 formaction 屬性。

注意: Internet Explorer 9 及更早IE版本不支持 formaction 屬性。


定義和用法

formaction 屬性覆蓋 form 元素的 action 屬性。

該屬性與 type="submit" 配合使用。


HTML 4.01 與 HTML5之間的差異

formaction 屬性是 HTML 5 中的新屬性。


語(yǔ)法

<button type="submit" formaction="URL">

屬性值

描述
URL 規(guī)定將表單數(shù)據(jù)發(fā)送到的地址。

可能值:

  • 絕對(duì) URL - 完整的頁(yè)面URL地址(如: rel="external nofollow" target="_blank" )
  • 相對(duì) URL 地址 -指向當(dāng)前網(wǎng)站的一個(gè)文件(如:href="formresult.html")


HTML button 標(biāo)簽參考手冊(cè)HTML <button> 標(biāo)簽