JavaScript实用的一些技巧

1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键

1<table border="" oncontextmenu="return(false)"><td>no</td></table>

可用于Table


2.

 1<body onselectstart="return false"> 取消选取、防止复制 
 2
 33\. onpaste="return false" 不准粘贴 
 4
 54\. oncopy="return false;" oncut="return false;" 防止复制 
 6
 75\. <link href="favicon.ico" rel="Shortcut Icon"/> IE地址栏前换成自己的图标 
 8
 96\. <link href="favicon.ico" rel="Bookmark"/> 可以在收藏夹中显示出你的图标 
10
117\. <input style="ime-mode:disabled"/> 关闭输入法 
12
138\. 永远都会带着框架   
14<script language="JavaScript"><!--   
15if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页   
16// --></script>
17
189\. 防止被人frame   
19<script language="JAVASCRIPT"><!--   
20if (top.location != self.location)top.location=self.location;   
21// --></script>
22
2310\. 网页将不能被另存为   
24<noscript><iframe src="*.html"></iframe></noscript>
25
2611\. <input "http:="" onclick="window.location = " type="button" value="查看网页源代码" view-source:"+="" www.pconline.com.cn""=""/>
27
2812.删除时确认   
29<a "="" href="javascript:if(confirm(" 确实要删除吗?"))location="boos.asp?&amp;areyou=删除&amp;page=1">删除</a>
30
3113\. 取得控件的绝对位置   
32//Javascript   
33<script language="Javascript">   
34function getIE(e){   
35var t=e.offsetTop;   
36var l=e.offsetLeft;   
37while(e=e.offsetParent){   
38t+=e.offsetTop;   
39l+=e.offsetLeft;   
40}   
41alert("top="+t+"/nleft="+l);   
42}   
43</script>
44
45//VBScript   
46<script language="VBScript"><!--   
47function getIE()   
48dim t,l,a,b   
49set a=document.all.img1   
50t=document.all.img1.offsetTop   
51l=document.all.img1.offsetLeft   
52while a.tagName<>"BODY"   
53set a = a.offsetParent   
54t=t+a.offsetTop   
55l=l+a.offsetLeft   
56wend   
57msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"   
58end function   
59\--></script>
60
61本新闻共  5  页,当前在第  1  页  1  2 3 4 5</body>
Published At
Categories with 网页设计
Tagged with
comments powered by Disqus