1. Completely block the right mouse button

[JavaScript]

Plain text view
Copy the code

?
1
2
Oncontextmenu = "window. The event. The returnValue =
false
"
< table border oncontextmenu=
return
(
false
)>< td>no< /table

2. Deselect and prevent replication

[HTML]

Plain text view
Copy the code

?
1
<
body
Onselectstart = "return false" >

3.JS does not allow pasting

[JavaScript]

Plain text view
Copy the code

?
1
Onpaste ="
return
false
"

4. JS prevents replication

[JavaScript]

Plain text view
Copy the code

?
1
Oncopy ="
return
false
;" Oncut ="
return
false
;"

5. Change the icon in front of the address bar of Internet Explorer

[HTML]

Plain text view
Copy the code

?
1
2
3
<
link
Rel = "Shortcut Icon" href = "favicon. Ico" >
Put the image in the root directory of the file and change the suffix to ICO

6. You can display your icon in favorites

[HTML]

Plain text view
Copy the code

?
1
<
link
Rel = "Bookmark" href = "favicon. Ico" >

7. Disable the input method

[HTML]

Plain text view
Copy the code

?
1
<
input
Style = "ime - mode: disabled" >

8. Always carry a frame

[HTML]

Plain text view
Copy the code

?
1
2
3
4
5
<
script
Language = "JavaScript" >
<! -- if (window == top)top.location.href = "frames. HTM"; //frames. HTM for frame pages // -- >
< /
script
>

9. Prevent frame

[HTML]

Plain text view
Copy the code

?
1
2
3
<
SCRIPT
LANGUAGE
=
JAVASCRIPT
> <! -
if (top.location ! = self.location)top.location=self.location;
/ / -- > < /
SCRIPT
>

10. Web pages cannot be saved as

[HTML]

Plain text view
Copy the code

?
1
<
noscript
><
iframe
src=*.html>< /
iframe
>< /
noscript
>

< input type=button value=

[JavaScript]

Plain text view
Copy the code

?
1
The onclick = "window. The location =" view - source: "+" [url = HTTP:
/ / www.pconline.com.cn] http://www.pconline.com.cn [/ url] ">"

12. Confirm the deletion

[HTML]

Plain text view
Copy the code

?
1
2
<
a
Href = "javascript:if(confirm(" do you want to delete? )) location = "boos. Asp? & areyou = delete
&
page
=
1
"> delete < /
a
>

13. Get the absolute position of the control

[AppleScript]

Plain text view
Copy the code

?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/
/
Javascript
<
script
language
=
"Javascript"
>
function getIE
(
e
)
{
var t
=
e.offsetTop;
var l
=
e.offsetLeft;
while
(
e
=
e.offsetParent
)
{
t
+
=
e.offsetTop;
l
+
=
e.offsetLeft;
}
console.
log
(
"Top
=
"
+
t
+
"
/
nleft
=
"
+
l
)
;
}
<
/
script
>
/
/
VBScript
<
script
language
=
"Script"
>
<
! -
function getIE
(
)
dim t
.
l
.
a
.
b
set
a
=
document
.all.img
1
t
=
document
.all.img
1.
offsetTop
l
=
document
.all.img
1.
offsetLeft
while a.tagName
<
>
"BODY"
set
a
=
a.offsetParent
t
=
t
+
a.offsetTop
l
=
l
+
a.offsetLeft
wend
Msgbox "top
=
"
&
t
&
chr
(
13
)
&
"Left
=
"
&
l
.
64
.
"Get the position of the control"
end
function
-
>
<
/
script
>

14. The cursor stops at the end of the text in the text box

[AppleScript]

Plain text view
Copy the code

?
01
02
03
04
05
06
07
08
09
10
11
12
<
script
language
=
"Javascript"
>
function cc
(
)
{
var e
=
event
.srcElement;
var r
=
e.createTextRange
(
)
;
r.moveStart
(
"
character
"
.
e.
value
.length
)
;
r.collapse
(
true
)
;
r.
select
(
)
;
}
<
/
script
>
<
input type
=
text
name
=
text
1
value
=
"
123
"An onfocus
=
"Cc
(
)
"
>

15. Determine the source of the previous page

[AppleScript]

Plain text view
Copy the code

?
1
2
javascript
:
document
.referrer

16. Minimize, maximize, and close Windows

[HTML]

Plain text view
Copy the code

?
01
02
03
04
05
06
07
08
09
10
<
object
id
=
hh1
Every "that ADB880A6 - cf D8FF - 11-9377-00 aa003b7a11" >
<
param
Name = "Command" value = "Minimize" > < /
object
>
<
object
id
=
hh2
Every "that ADB880A6 - cf D8FF - 11-9377-00 aa003b7a11" >
<
param
Name = "Command" Maximize value = "" > < /
object
>
<
OBJECT
id
=
hh3
Every "that adb880a6 - cf d8ff - 11-9377-00 aa003b7a11" >
<
PARAM
NAME = "Command" VALUE = "Close" > < /
OBJECT
>
<
input
type
=
button
Minimum value =
onclick
=
hh1
.Click()>
<
input
type
=
button
Maximum value =
onclick
=
hh2
.Click()>
<
input
type
=
button
Value = closed
onclick
=
hh3
.Click()>
This example applies to Internet Explorer

17. Mask function keys Shift,Alt,Ctrl

[HTML]

Plain text view
Copy the code

?
1
2
3
4
5
6
7
<
script
>
function look(){
if(event.shiftKey)
Console. log(" Do not press Shift! ); // Use ALT/CTRL instead
}
document.onkeydown=look;
< /
script
>

18. Web pages are not cached

[HTML]

Plain text view
Copy the code

?
1
2
3
4
<
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 "> ="

19. How to make forms non-convex?

[HTML]

Plain text view
Copy the code

?
1
2
3
4
<
input
type
=
text
Style = "border: 1 solid # 000000" >
or
<
input
type
=
text
Style = "border - left: none; border-right:none; border-top:none; border-bottom:
1 solid # 000000 "> < /
textarea
>

< div>< span>&< layer>

[HTML]

Plain text view
Copy the code

?
1
2
3
<
div
>(division) is used to define large sections of page elements, resulting in line transitions
<
span
> is used to define elements in the same line as <
div
The only difference is that there is no career change
<
layer
> is the ns flag, ie does not support, equivalent to <
div
>

For more technical information: Gzitcast