ITPub博客

首页 > IT职业 > IT职场 > 网站制作精华代码

网站制作精华代码

IT职场 作者:albertdong 时间:2021-09-09 10:00:08 0 删除 编辑

1.oncontextmenu="window.event.returnvalue=false"将彻底屏蔽鼠标右键 no可用于table

2.
取消选取、防止复制

3.onpaste="returnfalse"不准粘贴

4.oncopy="returnfalse;"oncut="returnfalse;"防止复制

5.ie地址栏前换成自己的图标

6.可以在收藏夹中显示出你的图标

7.关闭输入法

8.永远都会带着框架
<!--
if(window==top)top.location.href="frames.htm";//frames.htm
为框架网页
//-->

9.防止被人frame
<!--
if(top.location!=self.location)top.location=self.location;
//-->

10.网页将不能被另存为

11.查看网页源代码
onclick="window.location=view-source:+图片描述http://www.csdn.net/";;>

12.怎样通过asp的手段来检查来访者是否用了代理
""then
response.write"
您通过了代理服务器,"&_
"
真实的ip为
"&request.servervariables("http_x_forwarded_for")
endif
%>

13.取得控件的绝对位置

//javascript

functiongetie(e){
vart=e.offsettop;
varl=e.offsetleft;
while(e=e.offsetparent){
t+=e.offsettop;
l+=e.offsetleft;
}
alert("top="+t+"nleft="+l);
}

//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,"
得到控件的位置"
endfunction
-->

14.光标是停在文本框文字的最后

functioncc()
{
vare=event.srcelement;
varr=e.createtextrange();
r.movestart(character,e.value.length);
r.collapse(true);
r.select();
}

15.判断上一页的来源
asp:
request.servervariables("http_referer")

javascript:
document.referrer

网站制作技术---精华代码(三)

 28.检测某个网站的链接速度:
把如下代码加入区域中:

tim=1
setinterval("tim++",100)
b=1

varautourl=newarray()
autourl[1]="http://www.njcatv.net/"
autourl[2]="javacool.3322.net"
autourl[3]="http://www.sina.com.cn/"
autourl[4]=""
autourl[5]="http://www.cctv.com/"

functionbutt(){
document.write("")
for(vari=1;idocument.write("
测试中……>=》=》
")
document.write("刷新
>")
}
butt()
functionauto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="
链接超时
"}
else
{document.forms[0]["txt"+b].value="
时间"+tim/10+"秒
"}
b++
}
functionrun(){for(vari=1;ihttp://"/;;;+autourl+")>")}
run()


29.
各种样式的光标
auto
:标准光标
default
:标准箭头
hand
:手形光标
wait
:等待光标
text
:i形光标
vertical-text
:水平i形光标
no-drop
:不可拖动光标
not-allowed
:无效光标
help
:?帮助光标
all-scroll
:三角方向标
move
:移动标
crosshair
:十字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize

30.本地无缓存,每次自动刷新
response.expires=0
response.addheader"pragma","no-cache"
response.addheader"cache-control","private"

31.修改contenttype并下载gif等格式
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")
%>


32.
检查一段字符串是否全由数字组成
<!--
functionchecknum(str){return!/d/.test(str)}
alert(checknum("1232142141"))
alert(checknum("123214214a1"))
//-->

33.获得一个窗口的大小
document.body.clientwidth,document.body.clientheight
document.body.offsetwidth,document.body.offsetheight
有时还需要知道window.screentop,window.screenleft

34.怎么判断是否含有汉字
if(escape(str).indexof("%u")!=-1)alert("
含有汉字");
elsealert("
全是字符");

35.textarea自适应文字行数的多少
ie5.5+
可以用overflow-y:visible

36.日期减去天数等于第二个日期

functioncc(dd,dadd)
{
//
可以加上错误处理
vard=newdate(dd.replace("-","/"))
d.setdate(d.getdate()+dadd)
alert(d.getfullyear()+"
年"+(d.getmonth()+1)+"月"+d.getdate()+"日")
}
cc("2002-2-28",2)

网站制作技术---制作1px边框表格的几种方法

有过网页制作经验的朋友一定知道:一般来讲,把表格的边框定义为1px时,即border=1,而实际上是2px。而我们在很多时候需要那种真正的边框为1px的表格,下面就介绍几种方法。

  一、用嵌套表格

  用两个表格嵌套,外层的表格的长与宽比里层的多出2px,并设置对齐属性为水平居中、垂直居中,然后把外层表格的背景设为你需要的边框颜色,里层表格背景设为与网页背景相同,这样就实现我们的愿望了,实例如下:

  


  
  

  
  
  
  
  
  

  
 

  二、设置亮、暗边框颜色

  表格有亮边框(bordercolorlight)和暗边框(bordercolordark)两个属性,把表格边框(border)设为1px,亮边框(bordercolorlight)设为背景色,暗边框(bordercolordark)设为你需要的实际边框颜色就可以了,实列如下:
  

  


  
  
  
  
 

    三、用CSS定义(一)

  代码为:
  

  实例如下:

  


  
  
  
  
 

  如果你用过Frontpage xp,你会发现,在Frontpage xp中定义的表格默认的设置就是用CSS定义过了的。

  四、用CSS定义(二)

  代码为:
  

  实例如下:

  


  
  
  
  
 

  有一点一定要注意:这时候不要再设置表格边框(border)、亮边框(bordercolorlight)和暗边框(bordercolordark)属性,否则不会出现预想的结果。

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/106/viewspace-2814937/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-11

  • 博文量
    103
  • 访问量
    690