一、action=""和action="#"、沒有action屬性的作用相同,都是提交到當前頁面(也就是document.location.href)
二、action="currentPage.xxx":如果currentPage.xxx表示當前頁面,則提交到當前頁面,同事跳轉到當前頁面,當然就看不到url的變化;如果currentPage.xxx是非當前頁面,則提交到非當前頁面,也跳轉到非當前頁面
三、表單提交到自身時 action="" 與 action="currentPage.xxx" 的區別:
通常為了省事 , 我們一般將表單的 action 屬性設為 action=""/action="#",或者干脆不寫,但是這會造成一個問題 , 就是其實將 action 設為 action="" 時 , 表單提交時真正提交的頁面是action="currentPage.xxx?arguments=values&….", 也就是如果當前頁面帶有參數 , 參數也一並會提交 , 而且參數的優先級會高於 <form> 控件提交的參數,即如果 action="currentPage.xxx?arguments=values&…." 中的 arguments 有與 <form> 元素名相同的時候 ,獲取值時 action=”currentPage.xxx?arguments=values&….” 值會將 <form> 的值覆蓋,從頁得到不正確的值.
例 : SpecTop.asp 頁面是表單要提交的頁面 , 且有從上級頁面傳遞過來參數
action="" 真正提交時的頁面 : SpecTop.asp?ClassID=000100200005&SpeID=947&SpeType=3
如果 <form> 中有 <input type=”text” name=”SpeID” value=”1000”/>, 提交時得到的值將會是 947, 而不是 1000, 而 action=”currentPage.xxx” 就能得到1000