常用网页代码
1、控制横向和纵向滚动条的显隐?
去掉x轴 去掉y轴不显2、表格变色
onmouseout=”this.style.backgroundColor=””
style=”CURSOR: hand”>
3、禁止复制,鼠标拖动选取
oncontextmenu=window.event.returnValue=false
onselectstart=event.returnValue=false>
4、普通iframe页面
5、iframe自适应高度
6、IE地址栏前换成自己的图标&可以在收藏夹中显示出你的图标
7、字号缩放
越来越多的人长时间的泡网,眼镜的普及率也越来越高,让文字大点,让更多的用户看的更清楚。
function doZoom(size)
{document.getElementById(‘zoom’).style.fontSize=size+’px’;}
需要指定大小的文字
8、select挡住div的解决方法
在div里加入下面的代码,根据需要调整就可以了。
9、iframe(嵌入式帧)自适应高度
填写的嵌入地址一定要和本页面在同一个站点上,否则会提示“拒绝访问!”。对跨域引用有权限问题,请查阅其他资料。
10、跳转菜单新窗口
11、flash透明选项
12、添加到收藏夹和设为首页
13、记录并显示网页的最后修改时间
document.write(“最后更新时间: ” + https://www.360docs.net/doc/b13228074.html,stModified + “”)
14、节日倒计时
var timedate= new Date(“October 1,2002″);
var times= “国庆节”;
var now = new Date();
var date = timedate.getTime() – now.getTime();
var time = Math.floor(date / (1000 * 60 * 60 * 24));
if (time >= 0)
document.write( “现在离”+times+”还有: “+time +”天”)
15、加在HEAD里
禁止缓存
16、让IFRAME框架内的文档的背景透明
17、打开窗口即最大化
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
// End –>
18、加入背景音乐
19、滚动
20、防止点击空链接时,页面往往重置到页首端
代码“javascript:void(null)”代替原来的“#”标记
21、文字或图片弹出指定大小的窗口
在body中加入
function MM_openBrWindow(theURL,winName,features)
{window.open(theURL,winName,features);}
弹出代码
22、 flash按钮加链接
on (press) {
getURL(“https://www.360docs.net/doc/b13228074.html,”,”_blank”);
}
23、跳转页面代码
24、细线分隔线
25、网页中的自动换行
完整的是
style=”table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word”
26、消除ie6自动出现的图像工具栏,设置 GALLERYIMG属性为false或no .
27、禁止页面正文内容被选取
oncopy=”document.selection.empty()” onbeforecopy=”return
false”onmouseup=”document.selection.empty()”>
28、不能点右键,不用CTRL+A,不能复制作!
onkeypress=”window.event.returnValue=false”
onkeydown=”window.event.returnValue=false”
onkeyup=”window.event.returnValue=false”
ondragstart=”window.event.returnValue=false”
onselectstart=”event.returnValue=false”>
29、IE浏览器支持一个 Body 属性 bgproperties,它可以让背景不滚动:
30、随机变换背景图象(一个可以刷新心情的特效)
image = new Array(4); //定义image为图片数量的数组
image [0] = ‘tu0.gif’ //背景图象的路径
image [1] = ‘tu1.gif’
image [2] = ‘tu2.gif’
image [3] = ‘tu3.gif’
image [4] = ‘tu4.gif’
number = Math.floor(Math.random() * image.length);
document.write(“
”);31、flash载入影片
on (release)
{
loadMovie(“1-01.swf”, “_root.loaderclip”);
}
32、图片表单按钮
33、左右阴影背景的CSS定义方法
body {
text-align:center;
background-repeat: repeat-y;
background-position: center;
background-image: url(../images/bg.jpg);
}
34、划过链接手型鼠标
style=”cursor:hand”
35、如何关闭层
36、关闭窗口的脚本
37、如果文字过长,则将过长的部分变成省略号显示
38、进入主页后自动最大化
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
39、凹陷文字
style=”width:300px;padding:20p x;overflow:hidden;word-wrap:break-word;word-brea k:break:all; font-size:12px; line-height:18px; background-color:#eeeeee;”>
怎么样,我凹下去了吧?
你不想试试吗?
40、运行代码框
function Preview()
{var TestWin=open(”);
TestWin.document.write(code.value);}
41、给表格做链接
42、让弹出窗口总是在最上面
43、CSS文字阴影
.shadowfont{FILTER: dropshadow(color=#666666, offx=1, offy=1, positive=1); FONT-FAMILY: “宋体”; FONT-SIZE: 9pt;COLOR: #ffffff;}
44、后退&关闭窗口
后退:javascript:history.back(1)
关闭:javascript:window.close();
45、表格透明
style=”FILTER: alpha(opacity=72)”
46、如何避免别人把你的网页放在框架中
49、链接到
response.redirect”login.asp”
location.href=”xx.asp”
onClick=”window.location=’login.asp’”
onClick=”window.open(”)”
50、基本链接样式
a:link 表示链接的样式
a:active 表示当前活动连接的样式
a:hover 表示鼠标划过时的样式
a:visited 表示已经访问过的连接的样式
“link-visited-hover-active” 简记为“lvha” 即“love”+”hate”
51、在同一页面设置不同文字链接效果的样式
.green {COLOR: #309633}
.green A:link {COLOR: #309633; TEXT-DECORATION: none}
.green A:visited {COLOR: #309633; TEXT-DECORATION: none}
.green A:hover {COLOR: #309633; TEXT-DECORATION: underline}
.green A:active {COLOR: #309633; TEXT-DECORATION: none}