
- HTML 教程
- HTML - 首頁
- HTML - 路線圖
- HTML - 簡介
- HTML - 歷史與演變
- HTML - 編輯器
- HTML - 基本標籤
- HTML - 元素
- HTML - 屬性
- HTML - 標題
- HTML - 段落
- HTML - 字型
- HTML - 塊
- HTML - 樣式表
- HTML - 格式化
- HTML - 引用
- HTML - 註釋
- HTML - 顏色
- HTML - 圖片
- HTML - 圖片地圖
- HTML - 內聯框架 (iframe)
- HTML - 短語元素
- HTML - 元標籤
- HTML - 類
- HTML - ID
- HTML - 背景
- HTML 表格
- HTML - 表格
- HTML - 表頭與標題
- HTML - 表格樣式
- HTML - 表格列組 (colgroup)
- HTML - 巢狀表格
- HTML 列表
- HTML - 列表
- HTML - 無序列表
- HTML - 有序列表
- HTML - 定義列表
- HTML 連結
- HTML - 文字連結
- HTML - 圖片連結
- HTML - 郵箱連結
- HTML 顏色名稱與值
- HTML - 顏色名稱
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML 表單
- HTML - 表單
- HTML - 表單屬性
- HTML - 表單控制元件
- HTML - 輸入屬性
- HTML 多媒體
- HTML - 影片元素
- HTML - 音訊元素
- HTML - 嵌入多媒體
- HTML 頭部
- HTML - head 元素
- HTML - 新增 Favicon
- HTML - Javascript
- HTML 佈局
- HTML - 佈局
- HTML - 佈局元素
- HTML - 使用 CSS 進行佈局
- HTML - 響應式設計
- HTML - 符號
- HTML - 表情符號
- HTML - 樣式指南
- HTML 圖形
- HTML - SVG
- HTML - Canvas
- HTML API
- HTML - Geolocation API
- HTML - 拖放 API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web 儲存
- HTML - 伺服器傳送事件
- HTML 其他
- HTML - 文件物件模型 (DOM)
- HTML - MathML
- HTML - 微資料
- HTML - IndexedDB
- HTML - Web 訊息傳遞
- HTML - Web CORS
- HTML - WebRTC
- HTML 演示
- HTML - 音訊播放器
- HTML - 影片播放器
- HTML - 網頁幻燈片
- HTML 工具
- HTML - Velocity Draw
- HTML - 二維碼
- HTML - Modernizr
- HTML - 驗證
- HTML - 顏色拾取器
- HTML 參考
- HTML - 速查表
- HTML - 標籤參考
- HTML - 屬性參考
- HTML - 事件參考
- HTML - 字型參考
- HTML - ASCII 碼
- ASCII 碼錶查詢
- HTML - 顏色名稱
- HTML - 實體
- MIME 媒體型別
- HTML - URL 編碼
- 語言 ISO 程式碼
- HTML - 字元編碼
- HTML - 已棄用標籤
- HTML 資源
- HTML - 快速指南
- HTML - 有用資源
- HTML - 顏色程式碼生成器
- HTML - 線上編輯器
HTML - formaction 屬性
HTML formaction 屬性用於指定處理輸入控制元件並提交表單時重定向到不同頁面的檔案的 URL。它會覆蓋表單元素的 action 屬性。它與影像和提交型別的輸入元素一起使用,也與 <button> 元素一起使用。
例如,如果影像型別輸入元素存在 formaction 屬性,則當用戶點選影像時,它將重定向到不同的頁面。如果使用者提交表單,它將重定向到 <form> 元素的 action 屬性中指定的 URL。
語法
<tag formaction = "URL"></tag>
應用於
以下列出的元素允許使用 HTML formaction 屬性
HTML formaction 屬性示例
下面的例子將說明 HTML formaction 屬性,以及我們應該在哪裡以及如何使用這個屬性!
帶有 formaction 屬性的 input 元素
在下面的示例中,我們將使用 type=submit 的 HTML formaction 屬性。
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'formaction' attribute</title> </head> <body> <p> On clicking login button you will be redirected to index.html page of tutorialspoint as mentioned according to that in action attribute of form tag. </p> <form action="html/index.htm" method="get"> <label for="">Username</label> <input type="text"> <br> <br> <label for="">Password</label> <input type="password"> <br> <br> <input type="submit" value="Login"> </form> <br><br><hr><br> <p> Overriding the link in the action attribute of form tag using formaction attribute of input tag. This form will redirect you to tutorialspoint main page even though link to html page is present in action attribute. </p> <form action="html/index.htm" method="get"> <label for="">Username</label> <input type="text"> <br> <br> <label for="">Password</label> <input type="password"> <br> <br> <input type="submit" value="Login" formaction="https://tutorialspoint.tw"> </form> </body> </html>
帶有 formaction 屬性的 button 元素
考慮另一種情況,我們將使用 button 元素的 formaction 屬性。
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'formaction' attribute</title> </head> <body> <!--HTML 'formaction' attribute--> <p>Example of the HTML 'formaction' attribute</p> <form action="https://tutorialspoint.tw" method="get"> <label for="">Name</label> <input type="text"> <br> <br> <label for="">Email</label> <input type="email"> <br> <br> <label for="">Mobile</label> <input type="number"> <br> <br> <button>Submit 1</button> <button formaction="/html/index.htm">Submit 2</button> </form> <p> Submit 1 will redirect you home page of tutorialspoint as it's mentioned in action attribute of form tag, while submit 2 will override this using formaction and will submit to html page of tutorialspoint. </p> </body> </html>
支援的瀏覽器
屬性 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
formaction | 9.0 | 10.0 | 4.0 | 5.1 | 15.0 |
html_attributes_reference.htm
廣告