input type= submit html' target='_blank'>value= 提交
提交鏈接
a href= # quot;表單名字.submit() 提交 /a
重置按鈕
input type= reset value= 重置
重置鏈接
a href= # quot;表單名字.reset() 重置 /a
普通按鈕
input type= button value= 按鈕 quot;函數()
普通鏈接
a href= # quot;函數() 鏈接 /a
至于圖片也一樣把a標簽換成img
2、鏈接做成按鈕的樣子
a href= reg.asp 注冊 /a = input type= button value= 注冊 quot;location.href= reg.asp
-----------------------------------
有的時候我們完全可以手工做一個get方式的表單,至于用按鈕還是鏈接隨心所欲。
form action= xx.asp method= get name= form1 input name= aa type= text id= aa input name= bb type= text id= bb input type= submit name= Submit value= 提交 /form input name= aa type= text id= aa input name= bb type= text id= bb input type= button value= 按鈕 quot;location.href= xx.asp?aa= +document.all[ aa ].value+ bb= +document.all[ bb ].value
-----------------------------------
進一步說我們還可以做一個按鈕(鏈接)來同時傳遞js變量,表單input的值,asp變量,Recordset值
script language= javascript var id1=1; /script id3=3rs.open exec,conn,1,1假設有rs( id4 )=4 input name= id2 type= text id= id2 value= 2 input type= button value= 按鈕 quot;location.href= xx.asp?id1= +id1+ id2= +document.all[ id2 ].value+ id3= %=id3% id4= %=rs( id4 )%
我們按下按鈕會看到瀏覽器的url是xx.asp?id1=1 id2=2 id3=3 id4=4
在xx.asp中我們就可以用request.querystring來得到所有變量,這樣是不是變相的客戶端js和服務器段的變量傳遞?
------------------------------------------------------------------------------------------------------------------------------
如何給按鈕加上鏈接功能
解決思路:
按鈕屬于控件級的對象,優先級比較高,所以不能象圖片或文本一樣直接加鏈接,只能通過按鈕的單擊事件調用腳本的方式來實現。
具體步驟:
1.在原窗口打開鏈接
input type= button value= 閃吧 quot;location=’http://www.xxx.net’ button quot;location.href=’http://www.xxxx.net’ 閃吧 /button form action= http://www.xxxx.net%22%3e%3cinput/ type= submit value= 打開鏈接 /form
2.在新窗口中打開鏈接
input type= button value= 閃吧 quot;window.open(’http://www.xxxx.net’) button quot;window.open(’http://www.xxxx.net’) ggg /button form action= http://www.xxxx.net/ target= _blank input type= submit value= 打開鏈接 /form
注意:onClick調用的代碼里的引號在只有一重時可以單雙嵌套,超過兩重就必須用 / 號轉義且轉義的引號必須跟里層的引號一致,如:
button quot;this.innerHTML=’ font color=/’red/’ http://www.xxxx.net /font ’ 閃吧 /button
或
button this.innerHTML= font color=/ red/ http://www.xxxx.net /font ’ 閃吧 /button
而下面都是錯誤的寫法:
button quot;this.innerHTML=’ font color=’red’ http://www.xxxx.net /font ’ 閃吧 /button button quot;this.innerHTML=’ font color= red http://www.xxxx.net /font ’ 閃吧 /button button quot;this.innerHTML=’ font color=/ red/ http://www.xxxx.net /font ’ 閃吧 /button
提示:大部分屬于window或document對象的方法和屬性都可以省略前綴window或document,比如說本例中的location.href(location.href又可以簡寫為location,因為location的默認對象為href)就是window.location.href或document.location.href的省略式寫法。
技巧:本例中還可以用下面的方法來代替location.href
location.replace(url)location.assign(url)navigate(url)
特別提示
第一步中的代碼運行后,單擊按鈕將跳轉到鏈接目標。而第二步的在單擊按鈕后將在新窗口中打開鏈接。
特別說明
本例主要是通過用onClick捕獲用戶在按鈕上的單擊事件,然后調用location對象的href方法或window對象的open方法來打開鏈接。另外一個技巧是通過提交表單來實現鏈接功能,按鈕必須是type=submit類型的按鈕,表單的action值就是鏈接目標,target值就是鏈接打開的目標方式。
以上就是在html靜態頁面中給button加上提交鏈接的方法介紹的詳細內容,html教程
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
|
新聞熱點
疑難解答