标题:
[转帖]网页制作经典代码集(1)
[打印本页]
作者:
cnangel
时间:
2003-12-28 01:41
标题:
[转帖]网页制作经典代码集(1)
从前写过一个整理总结网页基本制作的文章。想不到的是在很多站点的BBS都有了转帖。想想看来还是有必要再将原来的东西系统的整理一下。搞出一篇更完整的网页基础常用代码收集来。----题记
网页经典代码(一)
1.将彻底屏蔽鼠标右键,无右键菜单
<body oncontextmenu="window.event.returnvalue=false">
也可以用于网页中Table框架中
<table border oncontextmenu=return(false)><td>no</table>
2.取消选取、防止复制
<body onselectstart="return false">
3.不准粘贴
<body onpaste="return false">
4.防止复制
<body oncopy="return false;" oncut="return false;">
5.IE地址栏前换成自己的图标
<link rel="Shortcut Icon" href="favicon.ico">
说明:关于favicon.ico文件的制作。你可以先在FW中做一个图片,属于你自己站点一个小图标。然后在ACD see将文件属性改为*.ico,然后将你做的*.ICO文件传到你的服务器目录中,然后就可以使用以上代码来实现,
当别人登陆你的站点时,地址栏里使用的就是你自定义的图标了。很PP哦。
6.可以在收藏夹中显示出你的图标
<link rel="Bookmark" href="favicon.ico">
说明:制作方法和上面的一样。只是显示的方式不同,这个是在别人收藏你的网页地址时显示的个性图标。也很PP.
7.关闭输入法 cidu.net
<input style="ime-mode:disabled">
说明:这段代码是在表格提交时用到的。也就是在输入数据时不可以使用其他输入法模式。
8.永远都会带着框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm";// --></script>
说明:frames.htm为你的网页,这也是保护页面的一种方法
9.防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
10.网页将不能被另存为
<noscript><iframe src=*.html></iframe></noscript>
说明:<noscirpt>的用法很广,其中一条就是可以使JS广告失效。
11.查源文件
<input type=button value=查看网页源代码
onclick="window.location = 'view-source:'+ 'http://www.cidu.net/test.htm';">
12.COOKIE脚本记录,有很大的用处哦
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = documents.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = documents.cookie.length;
returnvalue=unescape(documents.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie('popped')==''){
openpopup()
documents.cookie="popped=yes"
}
}
说明:以上是JS代码,请自己加起始符和结束符
13.内框架<IFRAME>使用
Iframe标记的使用格式是:
<iframe src="URL" width="x" height="x" scrolling="[OPTION]" frameborder="x"
name="main"></iframe>
src:文件的路径,既可是HTML文件,也可以是文本、ASP等; width、height:"内部框架"区域的宽与高;
scrolling:当SRC的指定的HTML文件在指定的区域不显不完时,滚动选项,如果设置为NO,则不出现滚动条;如为Auto:则自动出现滚动条;如为Yes,则显示;
FrameBorder:区域边框的宽度,为了让“内部框架“与邻近的内容相融合,常设置为0。
name:框架的名字,用来进行识别。
比如: 当你想用父框架控制内部框架时,可以使用: target="框架的名字"来控制。
例子:<iframe name="mm" src="http://www.cidu.net"; width="100%" height="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
14.自动跳转
在源代码中的<head>…</head>加入如下代码:
<meta http-equiv="refresh"content="3;URL=http://www.cidu.net; charset=gb2312">
说明:content="3 表示3秒刷新到URL
15.如何改变链接的鼠标形状
只需在链接上加上这一代码就行的了
或者跟上面的用CSS写也行
style="cursor:hand" style="cursor:crosshair"
style="cursor:text" style="cursor:wait"
style="cursor:move" style="cursor:help"
style="cursor:e-resize" style="cursor:n-resize"
style="cursor:nw-resize" style="cursor:w-resize"
style="cursor:s-resize" style="cursor:se-resize"
style="cursor:sw-resize"
以上代码你只需要加到连接或是页面的STYLE区里就可以实现鼠标多样化。
16.全屏显示
<form>
<div align="center">
<input type="BUTTON" name="FullScreen" value="全屏显示"
onClick="window.open(document.location, 'big', 'fullscreen=yes')">
</div>
</form>
把它放到<body>区中。
17.设为首页
<script language="javascript">
<!--
function defaul_home(){
this.home.style.behavior='url(#default#homepage)';this.home.setHomePage('http://www.cidu.net/';);
}
var focusok=false;
if (navigator.appName == "Netscape"){
focusok=true;
}
vers=navigator.appVersion;
if (navigator.appName == "Microsoft Internet Explorer"){
pos=vers.lastIndexOf('.');
vers=vers.substring(pos-1,vers.length);
}
proper_version=parseFloat(vers);
if(proper_version>=5){
focusok=true;
}
function launchstock1(htmlurl){
var stock=window.open(htmlurl,"stock",
"top=2,left=2,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=510");
if(focusok){
stock.focus();
}
return true;
}
function launchstock(){
var stock=window.open("","stock","top=2,left=2,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=510");
if(focusok){
stock.focus();
}
return true;
}
// -->
</script>
<a href="#" name="home" onClick="defaul_home();" title="==E代时光==">设为首页</a>
18.这里是加入收藏夹的代码
<a href="#" onClick="window.external.addFavorite('http://www.cidu.net';.'-=E代时光=-')" target="_self" title="-=E代时光=-">加入收藏夹</a>
19.flash图片效果
以下代码加入<head>区域
<SCRIPT language="javascript">
<!--
function makevisible(cur,which){
if (which==0)
cur.filters.alpha.opacity=100
else
cur.filters.alpha.opacity=20
}
//-->
</SCRIPT>
以下代码加入<body>区域
<img src="http://www.cidu.net/images/logo.gif"; style="filter:alpha(opacity=20)" onMouseOver="makevisible(this,0)" onMouseOut="makevisible(this,1)" width="63" height="56"> //图片地址请自己改
:ht04:
欢迎光临 星星博客 (http://commerce.huhoo.net/)
Powered by Discuz! 7.0.0