返回首页
当前位置: 主页 > 网络编程 > Asp实例教程 >

网页设计简单实用代码

时间:2010-06-03 20:36来源:知行网www.zhixing123.cn 编辑:麦田守望者

定制字体为“宋体12px”并去掉超链接的下横线
//在<HEAD>和</HEAD>之间插入

<style type="text/css">
BODY { FONT-FAMILY: "宋体","tahoma"; FONT-SIZE: 12px}
TH { FONT-FAMILY: "宋体", "tahoma"; FONT-SIZE: 12px}
TD { FONT-FAMILY: "宋体", "tahoma"; FONT-SIZE: 12px}
<!--
a {text-decoration:none}
a:hover {color: red;text-decoration:none}
-->
</style>
加入收藏(页面)
<script language>
<!--
if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4))
{
document.write("<U><SPAN STYLE=color:blue;cursor:hand; onclick=window.external.AddFavorite(location.href, document.title);>将本页添加到收藏夹</SPAN></U>");
}
//-->
</script>
加入收藏(网站)
<a href="javascript:window.external.AddFavorite(http://onegreen.126.com, 绿色软件站)">将本站加入收藏夹</a>
设为首页
<a href=# onClick="this.style.behavior=url(#default#homepage);this.setHomePage
(http://onegreen.126.com);">将本站设为首页</a>
自动显示当前日期<式样: 2003年8月4日(星期一) >
<script language="javascript">
var
today=new Date();var strDate=(" "+today.getYear()+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日");var n_day=today.getDay();switch(n_day)
{case 0:
{strDate=strDate+"(星期日)"
}break;case 1:
{strDate=strDate+"(星期一)"
}break;case 2:
{strDate=strDate+"(星期二)"
}break;case 3:
{strDate=strDate+"(星期三)"
}break;case 4:
{strDate=strDate+"(星期四)"
}break;case 5:
{strDate=strDate+"(星期五)"
}break;case 6:
{strDate=strDate+"(星期六)"
}break;case 7:
{strDate=strDate+"(星期日)"
}break;}document.write(strDate);
</script>
自动动态显示当前时间<式样:=>
上午8:51:09
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
<div id="Clock" align="center" style="font-size: 12; color:#FFFF00"></div>

自动显示当前日期和时间<式样:2003年8月4日 星期一 8:41am >
<script>
<!---
today=new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
var timeValue = "<FONT COLOR=#FFFF00>" + ((hours >12) ? hours -12 :hours); timeValue += ((minutes < 10) ? "<BLINK><FONT COLOR=#FFFF00>:</FONT></BLINK>0" : "<BLINK><FONT COLOR=#FFFF00>:</FONT></BLINK>") + minutes+"</FONT></FONT>";
timeValue += (hours >= 12) ? "<FONT COLOR=#FFFF00>pm</FONT>" : "<FONT COLOR=#FFFF00>am</FONT>";
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments }
var d=new initArray("<font color=#FFFF00>星期日","<font color=#FFFF00>星期一","<font color=#FFFF00>星期二","<font color=#FFFF00>星期三","<font color=#FFFF00>星期四","<font color=#FFFF00>星期五","<font color=#FFFF00>星期六"); document.write("<font color=#FFFF00><font color=#FFFF00>",today.getYear(),"<font color=#FFFF00>年","<font color=#FFFF00>",today.getMonth()+1,"<font color=#FFFF00>月","<font color=#FFFF00>",today.getDate(),"<font color=#FFFF00>日 </FONT>",d[today.getDay()+1]," ",timeValue);
//-->
</script>
自动显示主页最后更新日期<式样: 本页最后更新日期: 09/21/2002 23:39:17 >
<script>
<!--hide script from old browsers
document.write("本页最后更新日期: " + document.lastModified + "")
// end hiding -->
</script>
返回上一页
javascript:history.back();
页面自动跳转
在<head>和</head>之间加入如下代码:

<meta http-equiv="Refresh" content="30;URL=http://plugins.126.com">
页面自动刷新
在<head>和</head>之间加入如下代码:
<meta http-equiv="refresh" content="30">

固定背景图
在<head>和</head>之间加入如下代码:
<style type="text/css">
<!--
BODY
{
BACKGROUND-IMAGE: url(frames.gif);
BACKGROUND-REPEAT: no-repeat;
BACKGROUND-position: center;
BACKGROUND-ATTACHMENT: fixed;
}
-->
</style>
 

------分隔线----------------------------
标签(Tag):网页设计 网站制作
------分隔线----------------------------
推荐内容
猜你感兴趣