天天看点

JS按回车键实现登录的方法 JS按回车键实现登录的方法

JS????杞???瀹??扮?诲????规?

??绋匡?shichen2014 瀛?浣?锛?[ 澧???? ??灏?] 绫诲??锛?杞?杞? 杩?绡???绔?涓昏?浠?缁?浜?JS????杞???瀹??扮?诲????规?,??eb绋?搴?璁捐?′腑??甯稿???ㄧ????宸????ㄤ?琛ㄥ????浜ょ???????锋??寰?濂界???ㄦ?蜂?楠?,??瑕?????????浠ュ????涓? id="cproIframe_u1892994_2" width="580" height="90" src="http://pos.baidu.com/acom?adn=3&at=231&aurl=&cad=1&ccd=24&cec=GBK&cfv=18&ch=0&col=zh-CN&conBW=0&conOP=1&cpa=1&dai=2&dis=0&ltr=https%3A%2F%2Fwww.google.com%2F&ltu=http%3A%2F%2Fwww.jb51.net%2Farticle%2F54308.htm&lu_161=0&lunum=6&n=jb51_cpr&pcs=1903x971&pis=10000x10000&ps=426x486&psr=1920x1080&pss=1903x427&qn=ac40649ad75c81bd&rad=&rsi0=580&rsi1=90&rsi5=4&rss0=%23FFFFFF&rss1=%23F7FCFF&rss2=%230000ff&rss3=%23444444&rss4=%23008000&rss5=&rss6=%23e10900&rss7=&scale=&skin=tabcloud_skin_3&stid=5&td_id=1892994&titFF=%E5%AE%8B%E4%BD%93&titFS=12&titTA=left&tn=text_default_580_90&tpr=1438077106436&ts=1&version=2.0&xuanting=0&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&di=u1892994&ti=JS%E6%8C%89%E5%9B%9E%E8%BD%A6%E9%94%AE%E5%AE%9E%E7%8E%B0%E7%99%BB%E5%BD%95%E7%9A%84%E6%96%B9%E6%B3%95_javascript%E6%8A%80%E5%B7%A7_%E8%84%9A%E6%9C%AC%E4%B9%8B%E5%AE%B6&tt=1438077106412.134.318.329" align="center,center" marginwidth="0" marginheight="0" scrolling="no" frame allowtransparency="true">

????瀹?渚?璁茶堪浜?JS????杞???瀹??扮?诲????规?锛?璇ュ???芥??????甯稿箍娉???瀹??ㄤ环?笺????浜?缁?澶у?朵?澶у?跺????涔??ㄣ???蜂??规?濡?涓?锛?

?规?涓?锛?

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14

<

html

xmlns

=

"http://www.w3.org/1999/xhtml"

>

<

head

>

<

title

>Check Score</

title

>

<

script

language

=

"JavaScript"

>

function keyLogin(){

?

if (event.keyCode==13)? //??杞????????间负13

???

document.getElementByIdx_x("input1").click(); //璋??ㄧ?诲????????诲?浜?浠?/code>

}

</

script

>

</

head

>

<

body

onkeydown

=

"keyLogin();"

>

<

input

id

=

"input1"

value

=

"?诲?"

type

=

"button"

onClick

=

"alert('璋??ㄦ????锛?')"

>

</

body

>

</

html

>

?规?浜?锛?

?

1 2 3 4 5 6 7 8 9 10 11

<script>

function

KeyDown()

{

??

if

(event.keyCode == 13)

??

{

????

event.returnValue=

false

;

????

event.cancel =

true

;

????

Form1.btnsubmit.click();

??

}

}

</script>

浣跨?ㄦ?规?锛?

?

1 2 3 4 5

<

form

name

=

"Form1"

method

=

""

>

?ㄦ?峰??:<

INPUT

TYPE

=

text

SIZE

=

20

maxlength

=

8

onkeydown

=

KeyDown

()>

瀵???:<

INPUT

TYPE

=

password

SIZE

=

20

maxlength

=

8

onkeydown

=

KeyDown

()>

<

input

type

=

"submit"

name

=

"btnsubmit"

value

=

"??浜?

/>

</

form

>

?规?涓?锛?

浠讳?涓?涓?缃?绔?椤甸?㈤?芥???婚??????寰?澶??跺???ㄨ??ュソ?ㄦ?峰????瀵?????,杩?瑕??ㄩ????荤?逛?涓?绫讳技浜??婚??浠?涔????????????炬??杩??蜂????借?缃?绔???浣???娆㈠????浜???.

???跺????灏卞?ㄦ?虫??涓????藉?ㄨ??ュソ??璇ヨ??ョ??涓?瑗垮??,?存?ユ?插??杞?氨?ц??婚?????藉??瑙e?虫?规?濡?涓?锛?

ss.html椤甸??唬??:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

<

html

>

<

head

>

<

title

></

title

>

<

meta

http-equiv

=

"Content-Type"

content

=

"text/html; charset=gb2312"

>

<

link

rel

=

"stylesheet"

href

=

"css/text.css"

type

=

"text/css"

>

</

head

>

<

body

bgcolor

=

"#FFFFFF"

text

=

"#000000"

leftmargin

=

"0"

topmargin

=

"0"

marginwidth

=

"0"

marginheight

=

"0"

onkeydown

=

"on_return();"

>

??

<

form

name

=

"loginForm"

method

=

"post"

action

=

"fuck.html"

>???????

???

<

table

width

=

"100%"

border

=

"0"

cellspacing

=

"0"

cellpadding

=

"0"

>

?

<

tr

>

?

<

td

width

=

"69%"

height

=

"30"

><

span

class

=

"font_04"

>甯??峰??</

span

>

??

<

input

type

=

"text"

name

=

"userName"

size

=

"18.5"

>

?

</

td

>

????

</

tr

>

????

<

tr

>

?

<

td

width

=

"69%"

height

=

"30"

><

span

class

=

"font_04"

>瀵?????</

span

>

??

<

input

type

=

"password"

name

=

"pwd"

>

?

</

td

>

????

</

tr

>

????

<

tr

>

?

<

td

width

=

"31%"

height

=

"30"

>

?

<

a

id

=

"sub"

onClick

=

'check()'

>

?

?婚??</

a

></

td

>

????

</

tr

>

???

</

table

>

??

</

form

>

</

body

>

</

html

>

<

script

language

=

"javascript"

>

function check() {

????

var formname=document.loginForm;

???

if (formname.userName.value == "") {

????

alert("璇疯??ョ?ㄦ?峰??锛?");

????

formname.userName.focus();

????

return false;

??

}

??

if (formname.pwd.value == "") {

????

alert("璇疯??ュ????锛?");

????

formname.pwd.focus();

????

return false;

??

}

??

formname.submit();

}

??

//??杞??讹?榛?璁ゆ???婚??

?

function on_return(){

?

if(window.event.keyCode == 13){

??

if (document.all('sub')!=null){

???

document.all('sub').click();

???

}

?

}

?

}

</

script

>

姝ゅ?娉ㄦ??锛???lt;body>???㈡??浠???浜?onkeydown灞???杩??锋??浠?杈??ュソ??瀹瑰??????灏卞??浠ョ?存?ユ?ц?JS?规?on_return()浜?.??涓?indow.event.keyCode 濡?????13??璇?,琛ㄧず??杞???,??浠ユ??浠??ゆ????浠?????????涓?????杞???,濡???????浠?灏卞?绘??sub'灞?????濡??惧?颁??ц?click?规?灏辨??浜???

甯?????????杩版?规?瀵瑰ぇ瀹剁??web绋?搴?璁捐?℃????甯??┿??

继续阅读