In the past, we used js to determine whether the user was submitting by pressing ctrl + enter. Next I will introduce two page Jump methods by pressing the keyboard combination key.
Use a keyboard to redirect pages. Change the address after location to the address you want to jump to. The example is to use the direction key to implement the Code for the previous article and the next article on the MovableType log page.
The Code is as follows: |
Copy code |
<SCRIPT language = javascript> Document. onkeydown = chang_page; Function chang_page (){ If (event. keyCode = 37 | event. keyCode = 38) location = '<MTEntryPrevious> <$ MTEntryPermalink $> </MTEntryPrevious> '; If (event. keyCode = 39 | event. keyCode = 40) location = '<MTEntryNext> <$ MTEntryPermalink $> </MTEntryNext>' } </SCRIPT> |
P.S. numeric code corresponding to common buttons:
A (65), B (66), C (67), D (68), E (69), F (70), G (71), H (72), I (73), J (74), K (75), L (76), M (77), N (78), O (79), P (80) Q (81), R (82), S (83), T (84), U (85), V (86), W (87), X (88), Y (89), Z (90), 0 (48), 1 (49), 2 (50), 3 (51), 4 (52), 5 (53) 6 (54), 7 (55), 8 (56), 9 (57), up (38), down (40), left (37) and right (39 ).
Some common page Jump Codes
The Code is as follows: |
Copy code |
First: <Script language = "javascript" type = "text/javascript"> Window. location. href = "login. jsp? Backurl = "+ window. location. href; </Script> Second: <Script language = "javascript"> Alert ("return "); Window. history. back (-1 ); </Script> Third: <Script language = "javascript"> Window. navigate ("top. jsp "); </Script> Fourth: <Script language = "JavaScript"> Self.location+'top.htm '; </Script> Category 5: <Script language = "javascript"> Alert ("illegal access! "); Top. location = 'xx. jsp '; </Script> |
Add a ctrl + press enter to submit the form.
The Code is as follows: |
Copy code |
<Script language = javascript> Ie = (document. all )? True: false If (ie ){ Function ctlent (eventobject) {if (event. ctrlKey & amp; symbol event.keycode==13){this.doc ument. form1.submit ();}} } </Script> <Form action = "www. bKjia. c0m" method = POST name = form1> <Textarea cols = 95 name = Content rows = 12 wrap = virtual onkeydown = ctlent ()> Ctrl + Enter submit content </Textarea> <Input type = Submit value = "Submit" name = Submit> </Form> |