JavaScript for IE operation of the classic code of recommendations

  • 2020-03-30 02:17:41
  • OfStack

I've been working with ajax all this time, so I've had more opportunities to learn about JavaScript. I have collected some code on the Internet about the operation of JavaScript to IE (I can't remember exactly where cope is, so I will not add the source). I feel it is very useful in the development process. Of course, it only applies to IE, FF will have problems. Share now.


1. Will completely block the right mouse button 
oncontextmenu="window.event.returnvalue=false"
 Can be used to Table<table oncontextmenu=return(false)><td>no</table>
2. Unselect and prevent replication 
<bodyonselectstart="returnfalse">
3. Not allowed to paste 
onpaste="returnfalse"
4. To prevent copying 
oncopy="returnfalse;"
oncut="returnfalse;"
5.IE Replace the address bar with your own icon 
<linkrel="ShortcutIcon"href="favicon.ico">
6. Can show your icon in the favorites 
<linkrel="Bookmark"href="favicon.ico">
7. Close the input method 
<inputstyle="ime-mode:disabled">
8. Always carry the frame 
<scriptlanguage="javascript">
<!--
if(window==top)top.location.href="frames.htm";
//-->
</script>
9. To prevent being frame
<SCRIPTLANGUAGE=javascript>
<!--
if(top.location!=self.location)top.location=self.location;
//-->
</SCRIPT>
10. Web pages will not be saved as 
<noscript><iframesrc=*.html></iframe></noscript>
11. View web source code 
<input type=button value= View web source code  onclick="window.location='view-source:'+'//www.jb51.net/">
12. How to through asp To check whether the visitor has used an agent 
<%ifRequest.ServerVariables("HTTP_X_FORWARDED_FOR")<>""then
response.write"<fontcolor=#FF0000> You go through the proxy server, "&_
" The real IP for "&Request.ServerVariables("HTTP_X_FORWARDED_FOR")
endif
%>
13. Gets the absolute position of the control 
//javascript
<scriptlanguage="javascript">
functiongetIE(e)...{
vart=e.offsetTop;
varl=e.offsetLeft;
while(e=e.offsetParent)...{
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+" left="+l);
}
</script>
//VBScript
<scriptlanguage="VBScript"><!--
functiongetIE()
dimt,l,a,b
seta=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
whilea.tagName<>"BODY"
seta=a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox"top="&t&chr(13)&"left="&l,64," Gets the position of the control "
endfunction
-->
</script>
14. The cursor is at the end of the text box 
<scriptlanguage="javascript">
functioncc()
...{
vare=event.srcElement;
varr=e.createTextRange();
r.moveStart('character',e.value.length);
r.collapse(true);
r.select();
}
</script>
<inputtype=textname=text1value="123"onfocus="cc()">
15. Determine the source of the previous page 
asp:
request.servervariables("HTTP_REFERER")
javascript:
document.referrer
16. Minimize, maximize, and close the window 
<objectid=hh1classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<paramname="Command"value="Minimize"></object>
<objectid=hh2classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<paramname="Command"value="Maximize"></object>
<OBJECTid=hh3classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAMNAME="Command"value="Close"></OBJECT>
<inputtype=buttonvalue= To minimize the onclick=hh1.Click()>
<inputtype=buttonvalue= maximize onclick=hh2.Click()>
<inputtype=buttonvalue= Shut down onclick=hh3.Click()>
 This example applies to IE
17.
<%
' Defines some constants for database connections 
ConstadOpenForwardOnly=0' The cursor only browses the history forward, no paging, Recordset , BookMark
ConstadOpenKeyset=1' A keyset cursor, in which changes made by other users to the record are reflected in the recordset, but additions or deletions by other users are not reflected in the recordset. Support paging, Recordset , BookMark
ConstadOpenDynamic=2' Dynamic cursors are the most powerful, but also the most resource-intensive. Any changes the user makes to the record, additions or deletions are reflected in the recordset. Support full functional browsing (ACCESS Does not support ) . 
ConstadOpenStatic=3' A static cursor is just a snapshot of the data, and any changes the user makes to the record, adding or deleting the record, are not reflected in the recordset. Supports forward or backward movement 
ConstadLockReadOnly=1' Lock type, default, read-only, cannot be changed 
ConstadLockPessimistic=2' Locking records immediately while editing is the safest way 
ConstadLockOptimistic=3' Only when called Update Method when the recordset is locked, while other operations before the current record can still be changed, inserted, deleted, and so on 
ConstadLockBatchOptimistic=4' Records are not locked while editing, and changes, inserts, and deletes are done in batch mode 
ConstadCmdText=&H0001
ConstadCmdTable=&H0002
%>
18. Web pages are not cached 
HTM Web page 
<METAHTTP-EQUIV="pragma"CONTENT="no-cache">
<METAHTTP-EQUIV="Cache-Control"CONTENT="no-cache,must-revalidate">
<METAHTTP-EQUIV="expires"CONTENT="Wed,26Feb199708:21:57GMT">
 or <METAHTTP-EQUIV="expires"CONTENT="0">
ASP Web page 
Response.Expires=-1
Response.ExpiresAbsolute=Now()-1
Response.cachecontrol="no-cache"
PHP Web page 
header("Expires:Mon,26Jul199705:00:00GMT");
header("Cache-Control:no-cache,must-revalidate");
header("Pragma:no-cache");
19. Checks whether a string is composed entirely of Numbers 
<scriptlanguage="javascript"><!--
functioncheckNum(str){returnstr.match(/D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
//--></script>
20. Gets the size of a window 
document.body.clientWidth,document.body.clientHeight
21. How do you tell if it's a character 
if(/[^�-ÿ]/g.test(s))alert(" Contains Chinese characters ");
elsealert(" All characters ");
22.TEXTAREA The number of adaptive text lines 
<textarearows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>
23. Date minus days is equal to the second date 
<scriptlanguage=javascript>
functioncc(dd,dadd)
{
//You can add error handling
vara=newDate(dd)
a=a.valueOf()
a=a-dadd*24*60*60*1000
a=newDate(a)
alert(a.getFullYear()+" years "+(a.getMonth()+1)+" month "+a.getDate()+" day ")
}
cc("12/23/2002",2)
</script>
24. Which one was chosen Radio
<HTML><scriptlanguage="vbscript">
functioncheckme()
foreachobinradio1
ifob.checkedthenwindow.alertob.value
next
endfunction
</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. Get this page url the request.servervariables("") A collection of 
Response.Write"<TABLEborder=1><!--TableHeader--><TR><TD><B>Variables</B></TD><TD><B>value</B></TD></TR>"
foreachobinRequest.ServerVariables
Response.Write"<TR><TD>"&ob&"</TD><TD>"&Request.ServerVariables(ob)&"</TD></TR>"
next
Response.Write"</TABLE>"
26.
 This machine ip<%=request.servervariables("remote_addr")%>
 The server name <%=Request.ServerVariables("SERVER_NAME")%>
 The server IP<%=Request.ServerVariables("LOCAL_ADDR")%>
 Server port <%=Request.ServerVariables("SERVER_PORT")%>
 Server time <%=now%>
IIS version <%=Request.ServerVariables"SERVER_SOFTWARE")%>
 Script timeout <%=Server.ScriptTimeout%>
 This file path <%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
 The server CPU The number of <%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
 Server interpreter engine <%=ScriptEngine&"/" & ScriptEngineMajorVersion &"." & ScriptEngineMinorVersion & "." & ScriptEngineBuildVersion%>
 Server operating system <%=Request.ServerVariables("OS")%>
27.ENTER The key moves the cursor to the next input field 
<input onkeydown="if(event.keyCode==13)event.keyCode=9">
28. Check the link speed of a website: 
 Add the following code <body> In the area :
<scriptlanguage=javascript>
tim=1
setInterval("tim++",100)
b=1
varautourl=newArray()
autourl[1]="< src="pic/url.gif" align=absMiddle border=0>www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]="< src="pic/url.gif" align=absMiddle border=0>www.sina.com.cn"
autourl[4]="www.nuaa.edu.cn"
autourl[5]="< src="pic/url.gif" align=absMiddle border=0>www.cctv.com"
functionbutt(){
document.write("<formname=autof>")
for(vari=1;i<autourl.length;i++)
document.write("<inputtype=textname=txt"+i+"size=10value= In the test... >= " <inputtype=textname=url"+i+"size=40>= " <inputtype=buttonvalue=GOonclick=window.open(this.form.url"+i+".value)><br/>")
document.write("<inputtype=submitvalue= The refresh ></form>")
}
butt()
functionauto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value=" Connection timeout "}
else
{document.forms[0]["txt"+b].value=" time "+tim/10+" seconds "}
b++
}
functionrun(){for(vari=1;i<autourl.length;i++)document.write("<imgsrc=http://"+autourl[i]+"/"+Math.random()+"width=1height=1onerror=auto('< src="pic/url.gif" align=absMiddle border=0>http://";+autourl[i]+"')>")}
run()</script>
29. Various styles of cursors 
auto : standard cursor 
default : standard arrow 
hand : hand cursor 
wait : waiting for the cursor 
text : I Shape of the cursor 
vertical-text Level: I Shape of the cursor 
no-drop : do not drag the cursor 
not-allowed : invalid cursor 
help : ? Help the cursor 
all-scroll : trigonometric direction marker 
move : mobile standard 
crosshair : looked 
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
1. Local no cache, each automatic refresh 
response.expires=0
response.addHeader"pragma","no-cache"
response.addHeader"cache-control","private"
2. Modify the contentType And download gif Format such as 
<%
functiondl(f,n)
onerrorresumenext
sets=CreateObject("Adodb.Stream")
S.Mode=3
S.Type=1
S.Open
s.LoadFromFile(server.mappath(f))
iferr.number>0then
response.writeerr.number&":"&err.description
else
response.contentType="application/x-gzip"
response.addheader"Content-Disposition:","attachment;filename="&n
response.binarywrite(s.Read(s.size))
endif
endfunction
calldl("012922501.gif","t1.gif")
%>
19. Checks whether a string is composed entirely of Numbers 
<scriptlanguage="javascript"><!--
functioncheckNum(str)...{return!/D/.test(str)}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
//--></script>
20. Gets the size of a window 
document.body.clientWidth,document.body.clientHeight
document.body.offsetWidth,document.body.offsetHeight
 Sometimes you need to know window.screenTop,window.screenLeft
21. How to determine whether it contains Chinese characters 
if(escape(str).indexOf("%u")!=-1)alert(" Contains Chinese characters ");
elsealert(" All characters ");
22.TEXTAREA The number of adaptive text lines 
IE5.5+ You can use overflow-y:visible
<textarearows=1name=s1cols=27style="overflow-y:visible">
</textarea>
23. Date minus days is equal to the second date 
<scriptlanguage=javascript>
function cc(dd,dadd)
...{
//You can add error handling
vard=newDate(dd.replace("-","/"))
d.setDate(d.getDate()+dadd)
alert(d.getFullYear()+" years "+(d.getMonth()+1)+" month "+d.getDate()+" day ")
}
cc("2002-2-28",2)
</script>


Related articles: