逍 遥 谷

一些JavaScript 技巧 (吐血大奉送哦!)

   J2EE2005-3-30 17:43
1.本地无缓存,每次自动刷新
response.expires=0
response.addHeader "pragma" , "no-cache"
response.addHeader "cache-control" , "private"

2.ENTER键可以让光标移到下一个输入框
<input onkeydown="if(event.keyCode==13)event.keyCode=9">
3.
本机ip<%=request.servervariables("remote_addr")%>
服务器名<%=Request.ServerVariables("SERVER_NAME")%>
服务器IP<%=Request.ServerVariables("LOCAL_ADDR")%>
服务器端口<%=Request.ServerVariables("SERVER_PORT")%>
服务器时间<%=now%>
IIS版本<%=Request.ServerVariables"SERVER_SOFTWARE")%>
脚本超时时间<%=Server.ScriptTimeout%>
本文件路径<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
服务器CPU数量<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
服务器解译引擎<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>
服务器操作系统<%=Request.ServerVariables("OS")%>
4.
.获得本页url的request.servervariables("")集合
Response.Write "<TABLE border=1><!-- Table Header --><TR><TD><B>Variables</B></TD><TD><B>value</B></TD></TR>"
for each ob in Request.ServerVariables
Response.Write "<TR><TD>"&ob&"</TD><TD>"&Request.ServerVariables(ob)&"</TD></TR>"
next
Response.Write "</TABLE>"

5.TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>

6. 获得一个窗口的大小
document.body.clientWidth,document.body.clientHeight

7.. 最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>
<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=关闭 onclick=hh3.Click()>
本例适用于IE

8.. 光标是停在文本框文字的最后
<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=text1 value="123" onfocus="cc()">

9. <input type=button value=查看网页源代码
onclick="window.location = 'view-source:'+ 'http://www.csdn.net/'">
10. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
12. <body onselectstart="return false"> 取消选取、防止复制
13. onpaste="return false" 不准粘贴
14. oncopy="return false;" oncut="return false;" 防止复制
15. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
16. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
17. <input style="ime-mode:disabled"> 关闭输入法
18. 永远都会带着框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// --></script>
19. 防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
20. <noscript><iframe src=*.html></iframe></noscript> 网页将不能被另存为

标签集:TAGS:
回复Comments()点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}
Categories
-=Java 2,Html,XML等=-
Links
New Comments
Counter
RSS
我的 Blog:
romeo 最新的 20 条日志
[J2EE]
[Oracle]
[PowerBuilder]
[Linux]
[管理]
[个人随笔]
[休闲娱乐]
[经典瞬间]
全站 Blog:
全站最新的 20 条日志
Calendar