SoFunction
Updated on 2025-03-01

JavaScript shortcut key setting implementation code

Block Alt+F4 and other shortcut keys:
Copy the codeThe code is as follows:

<script>
function KeyDown(){ //Mask the right mouse button, Ctrl+n, shift+F10, F5 refresh, backspace key
//alert("ASCII code is: "+);
if (()&&
((==37)|| //Shield Alt+ arrow keys ←
(==39))){ //Shield Alt+ arrow keys →
alert("You are not allowed to use the ALT+ arrow keys to advance or back the web page!");
=false;
}
if ((==8) || //Mask backspace deletion key
(==116)|| //Shield F5 Refresh Key
(==112)|| //Mask F1 Refresh Key
( && ==82)){ //Ctrl + R
=0;
=false;
}
if (()&&(==78)) //Block Ctrl+n
=false;
if (()&&(==121)) //Shield shift+F10
=false;
if ( == "A" && )
= false; //Shift Shift Add the left mouse button to open a new web page
if (()&&(==115)){ //Shield Alt+F4
("about:blank","","dialogWidth:1px;dialogheight:1px");
return false;}
}
function Showhelp(){
alert("Wrong!");
return false;
}
</script>

==============================================================
IE Javascript shortcut key operation
1. oncontextmenu="=false" will completely block the right mouse button
<table border oncontextmenu=return(false)><td>no</table> can be used for Table
2. <body onselectstart="return false"> Unselect and prevent copying
3. onpaste="return false" is not allowed to paste
4. oncopy="return false;" oncut="return false;" prevents copying
5. <link rel="Shortcut Icon" href=../../../""> Change to your own icon in front of the IE address bar
6. <link rel="Bookmark" href=../../../""> You can display your icon in your favorites
7. <input style="ime-mode:disabled"> Close the input method
8. Always carry a frame
<script language="javascript"><!--
if (window == top) = ""; //For the frame web page
// --></script>
9. Prevent frames from being
<SCRIPT LANGUAGE=javascript><!--
if ( != )=;
// --></SCRIPT>
10. <noscript><iframe src=../../*.HTML></iframe></noscript> The web page will not be saved as
11. <input type=button value=View web page source code
onclick=" = 'view-source:'+ '/'">
12. How to check whether the client uses agents through ASP
<% if ("HTTP_X_FORWARDED_FOR")<>"" then
"<font color=#FF0000>You have passed the proxy server,"& _
"The real IP is"&("HTTP_X_FORWARDED_FOR")
end if
%>
13. Get the absolute position of the control
//javascript
<script language="javascript">
function getIE(e){
var t=;
var l=;
while(e=){
t+=;
l+=;
}
alert("top="+t+"\nleft="+l);
}
</script>
//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=.img1
t=.
l=.
while <>"BODY"
set a =
t=t+
l=l+
wend
msgbox "top="&t&chr(13)&"left="&l,64,"get the position of the control"
end function
--></script>
14. The cursor is stopped at the end of the text box
<script language="javascript">
function cc()
{
var e = ;
var r =();
('character',);
(true);
();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">
15. Determine the source of the previous page
ASP:
("HTTP_REFERER")
javascript:

16. Minimize, maximize, close windows
<object id=hh1 class>
<param name="Command" value="Minimize"></object>
<object id=hh2 class>
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 class>
<PARAM NAME="Command" VALUE="Close"></OBJECT>
<input type=button value=minimize onclick=()>
<input type=button value=maximize onclick=()>
<input type=button value=close onclick=()>
This example applies to IE
17.
<%
'Define some constants for database connection
Const adOpenForwardOnly = 0 'The cursor only browses the records forward, does not support paging, Recordset, BookMark
Const adOpenKeyset = 1 'Keyset cursor, the modifications made by other users to the record will be reflected in the record set, but other users add or delete records will not be reflected in the record set. Supports pagination, Recordset, BookMark
Const adOpenDynamic = 2 'The dynamic cursor has the strongest function, but also consumes the most resources. The modifications, additions or deletions of records by users to records will be reflected in the record set. Support full-featured browsing (ACCESS does not support).
Const adOpenStatic = 3 'Static cursor is just a snapshot of the data. The modifications made by the user to the record, addition or deletion of the records will not be reflected in the record set. Supports forward or backward movement
Const adLockReadOnly = 1 'Lock type, default, read-only, no modification can be made
Const adLockPessimistic = 2 'Lock records immediately when editing, the safest way
Const adLockOptimistic = 3 'The record set is locked only when the Update method is called, and other previous operations can still change, insert and delete the current record, etc.
Const adLockBatchOptimistic = 4 'The record will not be locked when editing, while changes, insertions and deletion are done in batch mode
Const adCmdText = &H0001
Const adCmdTable = &H0002
%>
18. The web page will not be cached
HTM web page
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
Or <META HTTP-EQUIV="expires" CONTENT="0">
ASP web page
= -1
= Now() - 1
= "no-cache"
PHP Web Page
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

19. Check whether a string is composed of numbers
<script language="javascript"><!--
function checkNum(str){return (/\D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
20. Get the size of a window
,
21. How to determine whether it is a character
if (/[^\x00-\xff]/(s)) alert("Contains Chinese characters");
else alert("all characters");
How many lines of adaptive text
<textarea rows=1 name=s1 cols=27 onpropertychange="=">
</textarea>
23. Date minus days equal to the second date
<script language=javascript>
function cc(dd,dadd)
{
//Error processing can be added
var a = new Date(dd)
a = ()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(a)
alert(() + "year" + (() + 1) + "month" + () + "day")
}
cc("12/23/2002",2)
</script>
24. Which Radio was selected
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if then
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>Style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" onclick="checkme()">
</BODY></HTML>
25. Obtain the ("") collection of urls on this page
"<TABLE border=1><!-- Table Header --><TR><TD><B>Variables</B></TD><TD><B>value</B></TD></TR>"
for each ob in
"<TR><TD>"&ob&"</TD><TD>"&(ob)&"</TD></TR>"
next
"</TABLE>"

26.
Native ip<%=("remote_addr")%>
Server name <%=("SERVER_NAME")%>
Server IP<%=("LOCAL_ADDR")%>
Server port <%=("SERVER_PORT")%>
Server time <%=now%>
IIS version<%="SERVER_SOFTWARE")%>
Script timeout <%=%>
The path of this file is <%=(("SCRIPT_NAME"))%>
Number of server CPUs <%=("NUMBER_OF_PROCESSORS")%>
Server interpretation engine <%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."& ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>
Server operating system <%=("OS")%>

The key moves the cursor to the next input box
<input onkeydown="if(==13)=9">

28. Detect the link speed of a certain website:
Add the following code to the <body> area:
<script language=javascript>
tim=1
setInterval("tim++",100)
b=1

var autourl=new Array()
autourl[1]=""
autourl[2]="javacool."
autourl[3]=""
autourl[4]=""
autourl[5]=""

function butt(){
("<form name=autof>")
for(var i=1;i<;i++)
("<input type=text name=txt"+i+" size=10 value=In test...> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=("+i+".value)><br/>")
("<input type=submit value=refresh></form>")
}
butt()
function auto(url){
[0]["url"+b].value=url
if(tim>200)
{[0]["txt"+b].value="Link timeout"}
else
{[0]["txt"+b].value="Time"+tim/10+"seconds"}
b++
}
function run(){for(var i=1;i<;i++)("<img src=http://"+autourl[i]+"/"+()+" width=1 height=1 onerror=auto('http://";+autourl[i]+"')>")}
run()</script>

29. Various styles of cursors
auto: standard cursor
default: standard arrow
hand: hand cursor
wait : Wait for the cursor
text: I-shaped cursor
vertical-text: horizontal I-shaped cursor
no-drop: The cursor cannot be dragged
not-allowed: Invalid cursor
help :?Help cursor
all-scroll: triangle direction mark
move: mobile tag
crosshair: crosshair
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize