现在的位置: 首页 > 综合 > 正文

网页经典代码

2014年02月17日 ⁄ 综合 ⁄ 共 8094字 ⁄ 字号 评论关闭

1.使网页不能被“另存为”
<body>里面加下面这段:
<noscript>
<iframe src="*.htm">
</iframe>
</noscript>

2.彻底屏蔽鼠标右键

<body>里面加上下面这段:
<script language="javascript">
<!--

if (window.Event)
document.captureEvents(Event.MOUSEUP);

function nocontextmenu()
{
event.cancelBubble = true
event.returnvalue = false;

return false;
}

function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnvalue = false;
return false;
}

}

document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//-->
</script>

3.超连接单元格变色

A:visited{TEXT-DECORATION: none}
A:active{TEXT-DECORATION: none}
A:hover{TEXT-DECORATION: underline overline}
A:link{text-decoration: none;}
表格单元,在单元格的<td>标记里加上:onMouseOut="this.style.backgroundColor='' "onMouseOver=this.style.backgroundColor='#E0E2ED'就可以了
onMouseOut="this.style.border='0px solid #cccccc';this.style.backgroundColor='' "onMouseOver="this.style.border='1px solid #cccccc';this.style.backgroundColor='#E0E2ED'"

4.细表格边框

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="158" height="68">
<tr>
<td width="158" height="68"> </td>
</tr>
</table>

5.网页全屏显示

把如下代码加入<body>区域中
<SCRIPT LANGUAGE="javascript">
<!-- Begin
if (this.name!='fullscreen'){
window.open(location.href,'fullscreen','fullscreen,scrollbars')
}
// End -->
</script>
<a href="javascript :window.close(self)">返回正常效果显示</a>

6.表格虚线

使用CSS,新建一个Style,选择“Redefine HTML Tag”,在下拉菜单中选择“td”,在弹出对话框中的“Category”里选择“Border”,将Top、Left、Right、Bottom都设成1px,颜色设成你想要的边框的颜色。然后在“Style”下拉框里选择“Dashed”,点“OK”。这样所有的表格都变成虚线的了。
或:
<table><td style="border:dashed 1px #00000">test</td></table>

7.连接全屏

<a href="#" onClick="window.open(URL,'','fullscreen=1')">Link</a>
通过连接可以打开一个全屏窗口

8.DW层的定位

用菜单插入层,不要用面板的。
主要就是不要设定层的left和right属性

9.css阴影滤镜

<div style="width:754;height:13;color:black;filter:dropshadow(color=white,offx=1,offy=1,positive=2);">  首页 关于本站 设计作品 </div>

<div style="width:75;height:1;color:black;filter:dropshadow(color=#cccccc,offx=1,offy=1,positive=2);" align="center"><font color="#414992"><a href="index.htm">首页</a></font></div>

10.关闭窗口

<a href="javascript :closewin();">关闭本页</a>
<script language=javascript>
function closewin() {window.close(); return;}
</script>

1.图层的准确定位

在单元格里Insert/Layer,插入一个图层A(通过菜单插入的图层是相对定位),他的位置是跟着参照物改变的。接着图层A中插入一个图层B。这时你可移动图层B到任何位置。这时图层B的位置是绝对的,但这个绝对植的起点不是浏览器的左上角。而是图层A。

1.自动连接到另一页

<meta http-equiv="refresh" content="5;URL=index.htm">

2.虚线表格

<title>虚线</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.unnamed1 { border: #000000; border-style: dotted; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">

<table width="289" border="0" cellpadding="0" cellspacing="0" class="unnamed1">
<tr>
<td width="289" height="220"></td>
</tr>
</table>
</body>

3.不同分辨率返回不同页面

<script language="javascript">
<!-- Begin
if ((screen.width == 640) && (screen.height == 480)){
self.location.href='640*480.htm'
}
else if ((screen.width == 800) && (screen.height == 600)){
self.location.href='800*600.htm'
}
else if ((screen.width == 1024) && (screen.height == 768)){
self.location.href='1024*768.htm'
}
else {self.location.href='else.htm'
}
// End -->
</script>

4.显示日期

<script language="javascript"><!--
today=new Date();
var week; var date;
if(today.getDay()==0) week="星期日"
if(today.getDay()==1) week="星期一"
if(today.getDay()==2) week="星期二"
if(today.getDay()==3) week="星期三"
if(today.getDay()==4) week="星期四"
if(today.getDay()==5) week="星期五"
if(today.getDay()==6) week="星期六"
date=(today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日"+" "
document.write("<span style='font-size: 9pt;'>"+date+week+"</span>");
// -->
</script>

5.表格一行多个
在table里加style="float:left"

27> 如何自动加入网页更改后的日期?
只需要在源文件<body></body>之间添加如下代码即可。

< Script Language=“JavaScript”><!--
document.write(“Last Updated:”+document.lastModified);
-->< /Script>

鼠标感应渐显图片代码
<script language="javascript1.2">
function makevisible(cur,which){
if (which==0)
cur.filters.alpha.opacity=100
else
cur.filters.alpha.opacity=20
}
</script>
<img src="tp1.gif" style="filter:alpha(opacity=20)" onMouseOver="makevisible(this,0)" onMouseOut="makevisible(this,1)">

(((<!--tp1.gif为图片源-->
<!--opacity数值可自定-->

cur.filters.alpha.opacity=100

cur.filters.alpha.opacity=20

两个数值分别用来控制图片在两种状态下的透明度。)))

插入单根虚线水平线
<hr style="border:dashed #0099cc; width:1px; height:300px">
<hr size="1" noshade style="border:none #cc9900; width:100%; height:1">
<hr size="1" noshade style="color:#ffccee; width:100%; height:1">

插入单根虚线水平线2
<p size=1 style="border:1px dotted #001403;">

如果要使Flash动画背景透明,我们需要在Dreamweaver中对动画进行设置:

  1.在DW中插入一个Flash动画,在对象属性栏中点击参数(Parameters)按钮;
  2、在参数设定对话框中,点击加号新建一参数,左边参数项填入Wmode,右边参数值填入Transparent;

  这样,用浏览器打开保存好的页面时,你就会发现Flash动画的背景已经变为透明。

  反映到HTML代码上,即是在插入Flash的<OBJECT>标签中插入以下代码:<param name=″Wmode″ value=″transparent″>

按纽,输入框等更改背景和线框颜色
在<input 后加入以下代码
class="purchase(为文字定义颜色的css名)" style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #993300"

表单里的文本框有提示文字,鼠标移上去就消失
在<input name="textfield1" 后加入onFocus="this.value=''"

改变文字,单元格所引用的css样式
<td onMouseOver="this.className='要变化的css名不要点号';"

半透明图片,鼠标移上去就完全显现
<img class="low" onMouseOver="this.className='high'"; onMouseOut="this.className='low'">
low为css设置好的半透明,high为css中设置好的完全显示

改变图片/按纽/文字的其他属性---以图片为例
<img src="img1" onMouseOver="this.src='img2'" onMouseOut="this.src='img1'">
如果改变图片的大小就将this.src改成this.width或者this.height

插入一个左上角带标题的表格
<fieldset style="width:220" align="center">
<legend>这里是表格的标题</legend>
这里添加表格中的内容
</fieldset>

表格可以带滚动条
在<td>与</td>中加入<div style="overflow:auto;height:160;">
这里输入文段的内容。
</div>

非常酷的黑色立体滚动条
<STYLE type="text/css">
<!--BODY {
scrollbar-face-color:#424542;
scrollbar-arrow-color:#CECFCE;
scrollbar-highlight-color:#636563;
scrollbar-3dlight-color:#000000;
scrollbar-shadow-color:#424542;
scrollbar-darkshadow-color:#000000;
scrollbar-track-color:#101010;
}--></STYLE>
放在<head>与</head>之间

进入页面需要密码。三次错误则退出[放在<body>与</body>之间]

<SCRIPT LANGUAGE="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('桔子私人资料请输入密码','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "loveorange") {
alert('密码正确!');
break;
}
testV+=1;
var pass1 =
prompt('密码错误!请勿尝试点取消退出:');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</SCRIPT>

发送表单至邮箱(为html格式不需要启动outlook)
<form action=http://gz.ce.net.cn/sendmail/sendmail.asp method=post
name=submitform>
<input name=sendemail type=hidden
value=sales@hotel-canton.net>
<input name=tHtml type=hidden>
后面加上放置表单的表格(里面可以添加多个表单元素)
发送按钮的代码必须为 <input id=button1 name=button1 onClick="submitform.tHtml.value=submitform.innerHTML; submitform.submit();" type=submit value=发送>将邮件地址改为需要即可

个性化鼠标指针
<A style="cursor: url('/imagesnew/software/030829/stopwtch.ani')" href="http://homepage.yesky.com/";>个性指针</a>

鼠标指向单元格变色
< td onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#FFcccc'"> </td>

在输入框中输入文字每按一个键背景就变色一次
<td><input onKeyUp="this.style.backgroundColor='#b4f3c7'" onKeyDown="this.style.backgroundColor='#cc3366'" type="text" name="textfield"></td>

表格阴影
新建一个滤镜css。然后将css里的相应位置替换成
filter:progid:DXImageTransform.Microsoft.Shadow
(Color=#333333,Direction=120,strength=5)">;
把这个css给表格使用。注意一定要给表格使用一种背景色

同一个页面内不同的文字有不同的链接色彩
新建css选择器 更改a:link 为 a.k1:link
a:visited 为 a.k1:visited
a:hover 为 a.k1:hover
而后将要链接的文字应用k1的css就可以了

屏蔽滚动条
<body scroll="no" style="overflow-y:hidden">

让浏览器窗口永远都不出现滚动条<body
style="overflow:hidden">

点击文字打开真正全屏幕窗口

在<head>与</head>之间插入以下代码
<SCRIPT language=JavaScript type=text/JavaScript>
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</SCRIPT>
在文字的链接框里输入
javascript :MM_openBrWindow('enterflash.htm','','toolbar=no,fullscreen=yes,location=no,status=no,menubar=no,scrollbars=no,resizable=no')
注: enterflash.htm为要打开的全屏幕窗口的网页文件地址
改 enterflash.htm文件里的<body>为<body style="overflow:hidden">
如果是设置成不需要点文字就可以的话就将启动全屏幕页面的<body>改为<body onload=MM_openBrWindow('enterflash.htm','','toolbar=no,fullscreen=yes,location=no,status=no,menubar=no,scrollbars=no,resizable=no')

抱歉!评论已关闭.