posts - 29,  comments - 3,  trackbacks - 0
 
在嵌入iframe的页面中:
程序代码
<iframe src="abc.htm" name="iframe" width="540" height="400" scrolling="Auto" frameborder="0" id="iframe" style="border:0px" allowtransparency="true"></iframe>


在该iframe被嵌入的页面中:

程序代码
<body STYLE="background-color: transparent">
posted @ 2006-05-29 20:52 死亡猎人 阅读(129) | 评论 (0)编辑 收藏

如何用CSS控制链接在新窗口打开

作者:dozb

一般控制链接在新窗口打开,我们在html中这样做:

<a class="newwinopen" href ="http://dozb.blogchina.com" target="_blank">http://dozb.blogchina.com</a>

可是要是对于同一页面的所有链接都要求在新窗口打开,在每个链接中都要写上target="_blank",未免有些烦琐。实际上,可以通过CSS来巧妙实现这个功能,代码如下:

<style>
a:active {
text:expression(target="_blank");
}
</style>
<a href ="http://dozb.blogchina.com">http://dozb.blogchina.com</a>

可以试一试点击下面的链接,看看效果如何:

http://dozb.blogchina.com

这里实际上是利用了style中的expression来执行javascript表达式,通过这个例子,我们可以举一反三,扩展到其他应用中去。

posted @ 2006-05-28 22:52 死亡猎人 阅读(356) | 评论 (0)编辑 收藏

利用XMLHTTP无刷新获取数据.

客户端和服务器端数据的交互有几种方法.
1.提交,通过<form></form>提交到服务器端.也称"有刷新"吧.
2.通过XMLHTTP无刷新提交到服务器端,并返回数据.也称"无刷新"吧.
利用XMLHTTP我们可以实现很多很强大的应用.这文章主要介绍它的一
些简单的应用.

附:因为XMLHTTP是IE5.0+支持的对象.所以你必须要有IE5.0+才能看到效果.

client.htm

<script language="JavaScript">
function GetResult(str)
{
/*
 *--------------- GetResult(str) -----------------
 * GetResult(str)
 * 功能:通过XMLHTTP发送请求,返回结果.
 * 参数:str,字符串,发送条件.
 * 实例:GetResult(document.all.userid.value);
 * author:wanghr100(灰豆宝宝.net)
 * update:2004-5-27 19:02
 *--------------- GetResult(str) -----------------
 */

    var oBao = new ActiveXObject("Microsoft.XMLHTTP");
    //特殊字符:+,%,&,=,?等的传输解决办法.字符串先用escape编码的.
    //Update:2004-6-1 12:22

    oBao.open("POST","server.asp?userid="+escape(str),false);
    oBao.send();
    //服务器端处理返回的是经过escape编码的字符串.
    document.all.username.value=unescape(oBao.responseText)
}
</script>
<input type="button" onclick="GetResult(document.all.userid.value)" value="Get"><br>
userid:<input type="text" name="userid"><br>
username:<input type="text" name="username">


server.asp  服务器端处理.

<% @Language="JavaScript" %>
<%
function OpenDB(sdbname)
{
/*
 *--------------- OpenDB(sdbname) -----------------
 * OpenDB(sdbname)
 * 功能:打开数据库sdbname,返回conn对象.
 * 参数:sdbname,字符串,数据库名称.
 * 实例:var conn = OpenDB("database.mdb");
 * author:wanghr100(灰豆宝宝.net)
 * update:2004-5-12 8:18
 *--------------- OpenDB(sdbname) -----------------
 */

    var connstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath(sdbname);
    var conn = Server.CreateObject("ADODB.Connection");
    conn.Open(connstr);
    return conn;
}
var sResult = "";
var oConn = OpenDB("data.mdb");
//特殊字符:+,%,&,=,?等的传输解决办法.客户端字符是经过escape编码的
//所以服务器端先要经过unescape解码.
//Update:2004-6-1 12:22

var userid = unescape(Request("userid"));
var sql = "select username from users where userid='"+userid+"'";
var rs = oConn.Execute(sql);
if(!rs.EOF)
{
    sResult = rs("username").Value;
}
else
{
    //加入容错.2004-5-30 10:15
    sResult = "Sorry,没有找到..."
}
//escape解决了XMLHTTP。中文处理的问题.
Response.Write(escape(sResult));
%>

数据库设计 data.mdb
表users.
字段
id  自动编号
userid  文本
username 文本

表:users 数据:
id userid  username
1 wanghr100 灰豆宝宝.net

posted @ 2006-05-28 22:28 死亡猎人 阅读(120) | 评论 (0)编辑 收藏
1.
-----------------------------------
<STYLE>
.tr1{BACKGROUND-COLOR:expression((this.sectionRowIndex%2==0)?"#cccccc":"#e6e6e6");}
</STYLE>  
<TABLE width=300  border=0 >
 <% for i=0 to 10%>
   <TR class="tr1"><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss1-->
 <%next%>  
</TABLE> 
--------------------------------------

2.
-------------------------------------
<SCRIPT>

//定义table的样式, cellSpacing,cellPadding.
//用obj.rows.length得出该表格的行数.
//实现奇数列时样式为tdcss1,偶数列为tbcss2.

function cooltable(obj) {
obj.cellSpacing=0;
obj.cellPadding=0;
for  (i=0;i<obj.rows.length;i++)  { 
if(i%2==0) obj.rows(i).className  =  "tdcss1"
else obj.rows(i).className  =  "tdcss2"; 

}
</SCRIPT>

<!--定义样式-->

<STYLE>
* {font-size: 10.5pt}
.tdcss1  {  BACKGROUND-COLOR:  #F7F3F7; } 
.tdcss2  {  BACKGROUND-COLOR:  #FFF7FF; } 
.mytbcss {baobao:expression(cooltable(this))}
</STYLE> 

<BODY> 

<!--定义定义表格样式mytbcss就可以得到一个双色相间表格,再也不用一行一行地定义了.-->

<TABLE width=300  border=0 class=mytbcss> 
   <TR><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss1-->
   <TR><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss2-->
   <TR><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss1-->
   <TR><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss2-->
   <TR><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss1-->
   <TR><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss2-->
   <TR><TD>wanghr100</TD><TD>灰豆宝宝.net</TD></TR>  <!--定义样式tdcss1-->
</TABLE> 
</BODY>
------------------------------
说明:


.tdcss1  {  BACKGROUND-COLOR:  #F7F3F7; } 
.tdcss2  {  BACKGROUND-COLOR:  #FFF7FF; } 
.mytbcss {baobao:expression(cooltable(this))}

.tdcss1.tdcss2 这两个是定义列的样式.
当然,你可以自己做得更酷一些啦..
baobao 是自已定义的属性,你任意取个名字,用你的英文名...因为这是你自己的CSS啊.

expression()里面的语句就是JavaScript. 一定很熟悉吧..
cooltable(this)调用了前面我们写的函数.

  这文章只是expression的一个小应用.看了这文章后,不知道有没有什么启发.
用expression给你的网页减减肥吧..让你的网页的代码更精减更模块化.....

posted @ 2006-05-28 22:02 死亡猎人 阅读(1435) | 评论 (1)编辑 收藏

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
#aa{ display:block; visibility:visible; }
</style>
<script language="javascript">
function ok()
{
document.getElementById("aa").style.visibility='hidden';
}
</script>
</head>

<body>
<div id="aa" onclick="ok();" >
asdsadsadsadsa
</div>
</body>
</html>

posted @ 2006-05-28 19:47 死亡猎人 阅读(81) | 评论 (0)编辑 收藏

<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> JavaScript: showPages v1.0 [by Lapuasi.com]</title>
<script language="JavaScript">
<!--
/*

showPages v1.1
=================================

Infomation
----------------------
Author : Lapuasi
E-Mail : lapuasi@gmail.com
Web : http://www.lapuasi.com
Date : 2005-11-17


Example
----------------------
var pg = new showPages('pg');
pg.pageCount = 12; //定义总页数(必要)
pg.argName = 'p';    //定义参数名(可选,缺省为page)
pg.printHtml();        //显示页数


Supported in Internet Explorer, Mozilla Firefox
*/

function showPages(name) { //初始化属性
 this.name = name;      //对象名称
 this.page = 1;         //当前页数
 this.pageCount = 1;    //总页数
 this.argName = 'page'; //参数名
 this.showTimes = 1;    //打印次数
}

showPages.prototype.getPage = function(){ //丛url获得当前页数,如果变量重复只获取最后一个
 var args = location.search;
 var reg = new RegExp('[\?&]?' + this.argName + '=([^&]*)[&$]?', 'gi');
 var chk = args.match(reg);
 this.page = RegExp.$1;
}
showPages.prototype.checkPages = function(){ //进行当前页数和总页数的验证
 if (isNaN(parseInt(this.page))) this.page = 1;
 if (isNaN(parseInt(this.pageCount))) this.pageCount = 1;
 if (this.page < 1) this.page = 1;
 if (this.pageCount < 1) this.pageCount = 1;
 if (this.page > this.pageCount) this.page = this.pageCount;
 this.page = parseInt(this.page);
 this.pageCount = parseInt(this.pageCount);
}
showPages.prototype.createHtml = function(mode){ //生成html代码
 var strHtml = '', prevPage = this.page - 1, nextPage = this.page + 1;
 if (mode == '' || typeof(mode) == 'undefined') mode = 0;
 switch (mode) {
  case 0 : //模式1 (页数,首页,前页,后页,尾页)
   strHtml += '<span class="count">Pages: ' + this.page + ' / ' + this.pageCount + '</span>';
   strHtml += '<span class="number">';
   if (prevPage < 1) {
    strHtml += '<span title="First Page">&#171;</span>';
    strHtml += '<span title="Prev Page">&#139;</span>';
   } else {
    strHtml += '<span title="First Page"><a href="javascript:' + this.name + '.toPage(1);">&#171;</a></span>';
    strHtml += '<span title="Prev Page"><a href="javascript:' + this.name + '.toPage(' + prevPage + ');">&#139;</a></span>';
   }
   for (var i = 1; i <= this.pageCount; i++) {
    if (i > 0) {
     if (i == this.page) {
      strHtml += '<span title="Page ' + i + '">[' + i + ']</span>';
     } else {
      strHtml += '<span title="Page ' + i + '"><a href="javascript:' + this.name + '.toPage(' + i + ');">[' + i + ']</a></span>';
     }
    }
   }
   if (nextPage > this.pageCount) {
    strHtml += '<span title="Next Page">&#155;</span>';
    strHtml += '<span title="Last Page">&#187;</span>';
   } else {
    strHtml += '<span title="Next Page"><a href="javascript:' + this.name + '.toPage(' + nextPage + ');">&#155;</a></span>';
    strHtml += '<span title="Last Page"><a href="javascript:' + this.name + '.toPage(' + this.pageCount + ');">&#187;</a></span>';
   }
   strHtml += '</span><br />';
   break;
  case 1 : //模式1 (10页缩略,首页,前页,后页,尾页)
   strHtml += '<span class="count">Pages: ' + this.page + ' / ' + this.pageCount + '</span>';
   strHtml += '<span class="number">';
   if (prevPage < 1) {
    strHtml += '<span title="First Page">&#171;</span>';
    strHtml += '<span title="Prev Page">&#139;</span>';
   } else {
    strHtml += '<span title="First Page"><a href="javascript:' + this.name + '.toPage(1);">&#171;</a></span>';
    strHtml += '<span title="Prev Page"><a href="javascript:' + this.name + '.toPage(' + prevPage + ');">&#139;</a></span>';
   }
   if (this.page % 10 ==0) {
    var startPage = this.page - 9;
   } else {
    var startPage = this.page - this.page % 10 + 1;
   }
   if (startPage > 10) strHtml += '<span title="Prev 10 Pages"><a href="javascript:' + this.name + '.toPage(' + (startPage - 1) + ');">...</a></span>';
   for (var i = startPage; i < startPage + 10; i++) {
    if (i > this.pageCount) break;
    if (i == this.page) {
     strHtml += '<span title="Page ' + i + '">[' + i + ']</span>';
    } else {
     strHtml += '<span title="Page ' + i + '"><a href="javascript:' + this.name + '.toPage(' + i + ');">[' + i + ']</a></span>';
    }
   }
   if (this.pageCount >= startPage + 10) strHtml += '<span title="Next 10 Pages"><a href="javascript:' + this.name + '.toPage(' + (startPage + 10) + ');">...</a></span>';
   if (nextPage > this.pageCount) {
    strHtml += '<span title="Next Page">&#155;</span>';
    strHtml += '<span title="Last Page">&#187;</span>';
   } else {
    strHtml += '<span title="Next Page"><a href="javascript:' + this.name + '.toPage(' + nextPage + ');">&#155;</a></span>';
    strHtml += '<span title="Last Page"><a href="javascript:' + this.name + '.toPage(' + this.pageCount + ');">&#187;</a></span>';
   }
   strHtml += '</span><br />';
   break;
  case 2 : //模式2 (前后缩略,页数,首页,前页,后页,尾页)
   strHtml += '<span class="count">Pages: ' + this.page + ' / ' + this.pageCount + '</span>';
   strHtml += '<span class="number">';
   if (prevPage < 1) {
    strHtml += '<span title="First Page">&#171;</span>';
    strHtml += '<span title="Prev Page">&#139;</span>';
   } else {
    strHtml += '<span title="First Page"><a href="javascript:' + this.name + '.toPage(1);">&#171;</a></span>';
    strHtml += '<span title="Prev Page"><a href="javascript:' + this.name + '.toPage(' + prevPage + ');">&#139;</a></span>';
   }
   if (this.page != 1) strHtml += '<span title="Page 1"><a href="javascript:' + this.name + '.toPage(1);">[1]</a></span>';
   if (this.page >= 5) strHtml += '<span>...</span>';
   if (this.pageCount > this.page + 2) {
    var endPage = this.page + 2;
   } else {
    var endPage = this.pageCount;
   }
   for (var i = this.page - 2; i <= endPage; i++) {
    if (i > 0) {
     if (i == this.page) {
      strHtml += '<span title="Page ' + i + '">[' + i + ']</span>';
     } else {
      if (i != 1 && i != this.pageCount) {
       strHtml += '<span title="Page ' + i + '"><a href="javascript:' + this.name + '.toPage(' + i + ');">[' + i + ']</a></span>';
      }
     }
    }
   }
   if (this.page + 3 < this.pageCount) strHtml += '<span>...</span>';
   if (this.page != this.pageCount) strHtml += '<span title="Page ' + this.pageCount + '"><a href="javascript:' + this.name + '.toPage(' + this.pageCount + ');">[' + this.pageCount + ']</a></span>';
   if (nextPage > this.pageCount) {
    strHtml += '<span title="Next Page">&#155;</span>';
    strHtml += '<span title="Last Page">&#187;</span>';
   } else {
    strHtml += '<span title="Next Page"><a href="javascript:' + this.name + '.toPage(' + nextPage + ');">&#155;</a></span>';
    strHtml += '<span title="Last Page"><a href="javascript:' + this.name + '.toPage(' + this.pageCount + ');">&#187;</a></span>';
   }
   strHtml += '</span><br />';
   break;
  case 3 : //模式3 (箭头样式,首页,前页,后页,尾页) (only IE)
   strHtml += '<span class="count">Pages: ' + this.page + ' / ' + this.pageCount + '</span>';
   strHtml += '<span class="arrow">';
   if (prevPage < 1) {
    strHtml += '<span title="First Page">9</span>';
    strHtml += '<span title="Prev Page">7</span>';
   } else {
    strHtml += '<span title="First Page"><a href="javascript:' + this.name + '.toPage(1);">9</a></span>';
    strHtml += '<span title="Prev Page"><a href="javascript:' + this.name + '.toPage(' + prevPage + ');">7</a></span>';
   }
   if (nextPage > this.pageCount) {
    strHtml += '<span title="Next Page">8</span>';
    strHtml += '<span title="Last Page">:</span>';
   } else {
    strHtml += '<span title="Next Page"><a href="javascript:' + this.name + '.toPage(' + nextPage + ');">8</a></span>';
    strHtml += '<span title="Last Page"><a href="javascript:' + this.name + '.toPage(' + this.pageCount + ');">:</a></span>';
   }
   strHtml += '</span><br />';
   break;
  case 4 : //模式4 (下拉框)
   if (this.pageCount < 1) {
    strHtml += '<select name="toPage" disabled>';
    strHtml += '<option value="0">No Pages</option>';
   } else {
    var chkSelect;
    strHtml += '<select name="toPage" onchange="' + this.name + '.toPage(this);">';
    for (var i = 1; i <= this.pageCount; i++) {
     if (this.page == i) chkSelect=' selected="selected"';
     else chkSelect='';
     strHtml += '<option value="' + i + '"' + chkSelect + '>Pages: ' + i + ' / ' + this.pageCount + '</option>';
    }
   }
   strHtml += '</select>';
   break;
  case 5 : //模式5 (输入框)
   strHtml += '<span class="input">';
   if (this.pageCount < 1) {
    strHtml += '<input type="text" name="toPage" value="No Pages" class="itext" disabled="disabled">';
    strHtml += '<input type="button" name="go" value="GO" class="ibutton" disabled="disabled"></option>';
   } else {
    strHtml += '<input type="text" value="Input Page:" class="ititle" readonly="readonly">';
    strHtml += '<input type="text" id="pageInput' + this.showTimes + '" value="' + this.page + '" class="itext" title="Input page" onkeypress="return ' + this.name + '.formatInputPage(event);" onfocus="this.select()">';
    strHtml += '<input type="text" value=" / ' + this.pageCount + '" class="icount" readonly="readonly">';
    strHtml += '<input type="button" name="go" value="GO" class="ibutton" onclick="' + this.name + '.toPage(document.getElementById(\'pageInput' + this.showTimes + '\').value);"></option>';
   }
   strHtml += '</span>';
   break;
  default :
   strHtml = 'Javascript showPage Error: not find mode ' + mode;
   break;
 }
 return strHtml;
}
showPages.prototype.createUrl = function (page) { //生成页面跳转url
 if (isNaN(parseInt(page))) page = 1;
 if (page < 1) page = 1;
 if (page > this.pageCount) page = this.pageCount;
 var url = location.protocol + '//' + location.host + location.pathname;
 var args = location.search;
 var reg = new RegExp('([\?&]?)' + this.argName + '=[^&]*[&$]?', 'gi');
 args = args.replace(reg,'$1');
 if (args == '' || args == null) {
  args += '?' + this.argName + '=' + page;
 } else if (args.substr(args.length - 1,1) == '?' || args.substr(args.length - 1,1) == '&') {
   args += this.argName + '=' + page;
 } else {
   args += '&' + this.argName + '=' + page;
 }
 return url + args;
}
showPages.prototype.toPage = function(page){ //页面跳转
 var turnTo = 1;
 if (typeof(page) == 'object') {
  turnTo = page.options[page.selectedIndex].value;
 } else {
  turnTo = page;
 }
 self.location.href = this.createUrl(turnTo);
}
showPages.prototype.printHtml = function(mode){ //显示html代码
 this.getPage();
 this.checkPages();
 this.showTimes += 1;
 document.write('<div id="pages_' + this.name + '_' + this.showTimes + '" class="pages"></div>');
 document.getElementById('pages_' + this.name + '_' + this.showTimes).innerHTML = this.createHtml(mode);
 
}
showPages.prototype.formatInputPage = function(e){ //限定输入页数格式
 var ie = navigator.appName=="Microsoft Internet Explorer"?true:false;
 if(!ie) var key = e.which;
 else var key = event.keyCode;
 if (key == 8 || key == 46 || (key >= 48 && key <= 57)) return true;
 return false;
}
//-->
</script>
<style>
/* Pages Main Tyle */
.pages {
 color: #000000;
 cursor: default;
 font-size: 10px;
 font-family: Tahoma, Verdana;
 padding: 3px 0px 3px 0px;
}
.pages .count, .pages .number, .pages .arrow {
 color: #000000;
 font-size: 10px;
 background-color: #F7F7F7;
 border: 1px solid #CCCCCC;
}
/* Page and PageCount Style */
.pages .count {
 font-weight: bold;
 border-right: none;
 padding: 2px 10px 1px 10px;
}
/* Mode 0,1,2 Style (Number) */
.pages .number {
 font-weight: normal;
 padding: 2px 10px 1px 10px;
}
.pages .number a, .pages .number span {
 font-size: 10px;
}
.pages .number span {
 color: #999999;
 margin: 0px 3px 0px 3px;
}
.pages .number a {
 color: #000000;
 text-decoration: none;
}
.pages .number a:hover {
 color: #0000ff;
}
/* Mode 3 Style (Arrow) */
.pages .arrow {
 font-weight: normal;
 padding: 0px 5px 0px 5px;
}
.pages .arrow a, .pages .arrow span {
 font-size: 10px;
 font-family: Webdings;
}
.pages .arrow span {
 color: #999999;
 margin: 0px 5px 0px 5px;
}
.pages .arrow a {
 color: #000000;
 text-decoration: none;
}
.pages .arrow a:hover {
 color: #0000ff;
}
/* Mode 4 Style (Select) */
.pages select, .pages input {
 color: #000000;
 font-size: 10px;
 font-family: Tahoma, Verdana;
}
/* Mode 5 Style (Input) */
.pages .input input.ititle, .pages .input input.itext, .pages .input input.icount {
 color: #666666;
 font-weight: bold;
 background-color: #F7F7F7;
 border: 1px solid #CCCCCC;
}
.pages .input input.ititle {
 width: 70px;
 text-align: right;
 border-right: none;
}
.pages .input input.itext {
 width: 25px;
 color: #000000;
 text-align: right;
 border-left: none;
 border-right: none;
}
.pages .input input.icount {
 width: 35px;
 text-align: left;
 border-left: none;
}
.pages .input input.ibutton {
 height: 17px;
 color: #FFFFFF;
 font-weight: bold;
 font-family: Verdana;
 background-color: #999999;
 border: 1px solid #666666;
 padding: 0px 0px 2px 1px;
 margin-left: 2px;
 cursor: hand;
}

/* body */
body {
 font-size: 12px;
}
</style>
</head>

<body>
<script language="JavaScript">
<!--
var pg = new showPages('pg');
pg.pageCount =12;  // 定义总页数(必要)
//pg.argName = 'p';  // 定义参数名(可选,默认为page)

document.write('<br>Show Times: ' + pg.showTimes + ', Mood Default');
pg.printHtml();
document.write('<br>Show Times: ' + pg.showTimes + ', Mood 0');
pg.printHtml(0);
document.write('<br>Show Times: ' + pg.showTimes + ', Mood 1');
pg.printHtml(1);
document.write('<br>Show Times: ' + pg.showTimes + ', Mood 2');
pg.printHtml(2);
document.write('<br>Show Times: ' + pg.showTimes + ', Mood 3 (only IE)');
pg.printHtml(3);
document.write('<br>Show Times: ' + pg.showTimes + ', Mood 4');
pg.printHtml(4);
document.write('<br>Show Times: ' + pg.showTimes + ', Mood 5');
pg.printHtml(5);
//-->
</script>
</body>
</html>

posted @ 2006-05-28 19:05 死亡猎人 阅读(80) | 评论 (0)编辑 收藏

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<script language="javascript" type="text/javascript">


startColor = "#671700"; // 定义链接颜色
endColor = "#D8D1C5";  // 定义要渐变到最后的颜色

stepIn = 17;
stepOut = 23;

/*
定义是否让所有的文本链接自动渐变,true为是,false为否
*/
autoFade = true; 

/*
在这里定义css样式里的类class:fade,如果为true,那么你要将要渐变的链接上加上此fade样式
*/
sloppyClass = false;

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

document.onmouseover = domouseover;
document.onmouseout = domouseout;

startColor = dehexize(startColor.toLowerCase());
endColor = dehexize(endColor.toLowerCase());

var fadeId = new Array();

function dehexize(Color){
 var colorArr = new makearray(3);
 for (i=1; i<7; i++){
  for (j=0; j<16; j++){
   if (Color.charAt(i) == hexa[j]){
    if (i%2 !=0)
     colorArr[Math.floor((i-1)/2)]=eval(j)*16;
    else
     colorArr[Math.floor((i-1)/2)]+=eval(j);
   }
  }
 }
 return colorArr;
}

function domouseover() {
  if(document.all){
   var srcElement = event.srcElement;
   if ((srcElement.tagName == "A" && autoFade) || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1))
        fade(startColor,endColor,srcElement.uniqueID,stepIn);     
   }
}

function domouseout() {
  if (document.all){
   var srcElement = event.srcElement;
    if ((srcElement.tagName == "A" && autoFade) || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1))
        fade(endColor,startColor,srcElement.uniqueID,stepOut);
    }
}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];}

function setColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(s,e, element,step){
 var sr = s[0]; var sg = s[1]; var sb = s[2];
 var er = e[0]; var eg = e[1]; var eb = e[2];
 
 if (fadeId[0] != null && fade[0] != element){
  setColor(sr,sg,sb,eval(fadeId[0]));
  var i = 1;
  while(i < fadeId.length){
   clearTimeout(fadeId[i]);
   i++;
   }
  }
 
    for(var i = 0; i <= step; i++) {
     fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
   step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
   ")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
  }
 fadeId[0] = element;
}

</script>

</BODY>
</HTML>
<A HREF="">让你的文本链接渐隐渐显</A>

posted @ 2006-05-28 19:02 死亡猎人 阅读(87) | 评论 (0)编辑 收藏
大家想必都知道,onfocus=”this.blur()”这条代码能消除链接时的虚线框,但你有没有想过,如果你的网页上有几个甚至上百个链接,而你又想要去掉上面那些讨厌的虚线框,难道你还一个个去Ctrl+C、Ctrl+V,天哪!这对一个正常人来说绝对是个恶梦。也许你会说,用DW或其它文本编辑器里的“查找/替换”功能就能解决,对!不可否认,这是一个好办法,但作为一个优秀的web developer,用尽可能少的代码实现一样的功能才是我们应当追求的目标,下面我们就用htc来解决这问题。至于htc是什么,全称就是Html Components,由微软在IE5.0后开始提供的一种新的指令组合,它可以把某种特定功能的代码封装在一个组件之中,从而实现了代码的重复使用。作为一个组件,htc里包含了属性、方法、事件等等各种知识,在这里就不一一介绍了,具体内容各位可以参考微软的msdn主页。

  回到开始处,Onfocus=this.blur()在这里很显然,onfocus是一个事件,this.blur()则是被事件所触发的对象,既然这点明确了,代码就知道该怎么写了。

<public:attach event=”onfocus” onevent=”example()” />
<script language=”javascript”>
function example(){
this.blur();
}
</script>

  将以上代码存为.htc为扩展名的文件,然后再编写一个普通的html网页

<html>
<head>
<style>
a {behavior:url(htc文件所在路径地址)}
</style>
<body>
<a href=”#”>链接1</a>
<a href=”#”>链接2</a>
<a href=”#”>链接3</a>
点链接试试,没有虚线框了吧
</body>
</html>

  OK,保存,预览,怎么样?效果出来了吧,再看看代码,的确精简了不少,而且在链接越多时体现得越发明显。最后我要说的是,这还仅仅是htc应用上的冰山一角而已,更多的功能还需要你们去认识,相信有点JS与CSS基础的你一定能学有所成。

posted @ 2006-05-28 18:55 死亡猎人 阅读(74) | 评论 (0)编辑 收藏

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
* {
 margin: 0; padding:0
}
body {
 margin-top: 10px;
 margin-right: auto;
 margin-bottom: 10px;
 margin-left: auto;
 text-align: center;
 height: auto;
 width: auto;
 background-color: #666666;
 font-size: 12px;
 color: #000000;
}
#container {
 text-align: left;
 width: 760px;
 height: 400px;
 background-color: #FFFFFF;
 padding: 20px;
}

#container #title {
 height: 28px;
}
#container #title li {
 float: left;
 list-style-type: none;
 height: 28px;
 line-height: 28px;
 text-align: center;
 margin-right: 1px;
}
#container #title ul {
 background-color: #FFFFFF;
 height: 28px;
}
#container #title a {
 text-decoration: none;
 color: #000000;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -29px;
}
#container #title a span{
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -29px;
 padding: 0 15px 0 15px;
}
#container #title #tag1 a:hover {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -87px;
}
#container #title #tag1 a:hover span{
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -87px;
 padding: 0 15px 0 15px;
}
#container #title #tag2 a:hover {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left 0px;
}
#container #title #tag2 a:hover span{
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right 0px;
 padding: 0 15px 0 15px; 
}
#container #title #tag3 a:hover {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -58px;
}
#container #title #tag3 a:hover span{
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -58px;
 padding: 0 15px 0 15px; 
}
#container #title #tag4 a:hover {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -145px;
}
#container #title #tag4 a:hover span{
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -145px;
 padding: 0 15px 0 15px;
}
#container #title #tag5 a:hover {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -174px;
}
#container #title #tag5 a:hover span{
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -174px;
 padding: 0 15px 0 15px;
}
#container #title .selectli1 {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -87px;
}
#container #title a .selectspan1 {
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -87px;
 padding: 0 15px 0 15px;
}
#container #title .selectli2 {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left 0px;
}
#container #title a .selectspan2 {
 display: block;

 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right 0px;
 padding: 0 15px 0 15px;
}
#container #title .selectli3 {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -58px;
}
#container #title a .selectspan3 {
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -58px;
 padding: 0 15px 0 15px;
}
#container #title .selectli4 {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -145px;
}
#container #title a .selectspan4 {
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -145px;
 padding: 0 15px 0 15px;
}
#container #title .selectli5 {
 text-decoration: none;
 color: #ffffff;
 display: block;
 width: auto;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif) no-repeat left -174px;
}
#container #title a .selectspan5 {
 display: block;
 background: url(http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif) no-repeat right -174px;
 padding: 0 15px 0 15px;
}
#container #content ul {margin: 10px;}
#container #content li {margin: 5px; }
#container #content li img {margin: 5px;display:block;}
#container #content {
 height: 300px;
 padding: 10px;
}
.content1 {
 border-top-width: 3px;
 border-right-width: 1px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #3A81C8;
 border-right-color: #3A81C8;
 border-bottom-color: #3A81C8;
 border-left-color: #3A81C8;
 background-color: #DFEBF7;
}
.content2 {
 border-top-width: 3px;
 border-right-width: 1px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #ff950b;
 border-right-color: #ff950b;
 border-bottom-color: #ff950b;
 border-left-color: #ff950b;
 background-color: #FFECD2;
}
.content3 {
 height: 300px;
 padding: 10px;
 border-top-width: 3px;
 border-right-width: 1px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #FE74B8;
 border-right-color: #FE74B8;
 border-bottom-color: #FE74B8;
 border-left-color: #FE74B8;
 background-color: #FFECF5;
}
.content4 {
 height: 300px;
 padding: 10px;
 border-top-width: 3px;
 border-right-width: 1px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #00988B;
 border-right-color: #00988B;
 border-bottom-color: #00988B;
 border-left-color: #00988B;
 background-color: #E8FFFD;
}
.content5 {
 height: 300px;
 padding: 10px;
 border-top-width: 3px;
 border-right-width: 1px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #A8BC1F;
 border-right-color: #A8BC1F;
 border-bottom-color: #A8BC1F;
 border-left-color: #A8BC1F;
 background-color: #F7FAE2;
}
.hidecontent {display:none;}
-->
</style>
<script language="javascript">
function switchTag(tag,content)
{
// alert(tag);
// alert(content);
 for(i=1; i <6; i++)
 {
  if ("tag"+i==tag)
  {
   document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i;
   document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i;
  }else{
   document.getElementById("tag"+i).getElementsByTagName("a")[0].className="";
   document.getElementById("tag"+i).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";
  }
  if ("content"+i==content)
  {
   document.getElementById(content).className="";
  }else{
   document.getElementById("content"+i).className="hidecontent";
  }
  document.getElementById("content").className=content;
 }
}
</script>
</head>

<body>
<div id="container">
  <div id="title">
    <ul>
      <li id="tag1"><a href="#" onclick="switchTag('tag1','content1');this.blur();" class="selectli1"><span class="selectspan1">首页</span></a></li>
      <li id="tag2"><a href="#" onclick="switchTag('tag2','content2');this.blur();"><span>下载中心</span></a></li>
      <li id="tag3"><a href="#" onclick="switchTag('tag3','content3');this.blur();"><span>产品介绍</span></a></li>
      <li id="tag4"><a href="#" onclick="switchTag('tag4','content4');this.blur();"><span>会员注册与登录</span></a></li>
      <li id="tag5"><a href="#" onclick="switchTag('tag5','content5');this.blur();"><span>联系我们</span></a></li>
    </ul>
  </div>
<div id="content" class="content1">
  <div id="content1"><p>仿淘宝网站的导航效果。此方法有几个优点:</p>1、根据字数自适应项目长度</div> 
  <div id="content2" class="hidecontent">2、不同的项目使用不同的颜色来区分</div>
  <div id="content3" class="hidecontent">3、这回需要使用到js了,呵呵</div>
  <div id="content4" class="hidecontent">4、背景图片只需要两个图片文件就足够,减少服务器负担</div>
  <div id="content5" class="hidecontent">5、这是使用到的两个图片:
         <table width="58%" border="1" cellspacing="2" cellpadding="0">
           <tr>
             <td width="70%" align="center"><img src="http://pics.taobao.com/2k5/sys/component/tab_selected_left_bk2.gif" width="250" height="290" /></td>
             <td width="30%" align="center"><img src="http://pics.taobao.com/2k5/sys/component/tab_selected_right_bk2.gif" width="15" height="290" /></td>
           </tr>
         </table>
  </div>
</div> 

</div>
</body>
</html>

 

posted @ 2006-05-28 18:50 死亡猎人 阅读(90) | 评论 (0)编辑 收藏
        上一次已经遇到一次这种情况了,后来总算找到原因,没有想到今天重装系统后又忘掉了,上次也没有记录下来,害的这次又折腾了一会,真是重复劳动,学乖点,这次给记下来,不知道有没有朋友也像我这样

Windows Server 2003 默认安装,是不安装 IIS 6 的,需要另外安装。安装完 IIS 6,还需要单独开启对于 ASP 的支持。

方法是:

控制面板 -> 管理工具 -> Internet 信息服务(IIS)管理器 -> Web 服务扩展 -> Active Server Pages -> 允许。

同时最好启用父路径

Internet 信息服务(IIS)管理器 -> 网站属性 -> 主目录 -> 应用程序设置 -> 配置 -> 选项 -> 启用父路径

Win 2003 默认安装下,许多选项都不启用,需要手动设置,虽然麻烦一点,但对于服务器来说,安全第一。
 
posted @ 2006-05-28 17:56 死亡猎人 阅读(254) | 评论 (0)编辑 收藏
仅列出标题
共3页: 1 2 3