document.body.scrollTop的返回值总是零的处理方法

四月 29, 2009 作者:fangds   类别:HTML, JAVASCRIPT 已经有694次浏览

为什么document.body.scrollTop的值总是零呢?原来是头部声明的问题,也是标准的问题。

原来在HTML文件头部声明了这样一句:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>

改成这样就好了:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

var scrollPos;
if (typeof window.pageYOffset != ‘undefined’) {
   scrollPos = window.pageYOffset;
}
else if (typeof document.compatMode != ‘undefined’ &&
     document.compatMode != ‘BackCompat’) {
   scrollPos = document.documentElement.scrollTop;
}
else if (typeof document.body != ‘undefined’) {
   scrollPos = document.body.scrollTop;
}
alert(scrollPos);

一切OK.

A链接的样式属性全解

四月 21, 2009 作者:fangds   类别:HTML 已经有475次浏览

1、不同状态下的解释
link:连接平常的状态  
active:连接被按下的时候  
visited:连接被访问过之后  
hover:鼠标放到连接上的时候

2、a:hover和a:visited书写顺序的重要性
今天在用a:hover属性的时候发现一个奇怪的问题,同一个页面里面有些链接的a:hover效果不能正常表现出来。链接的代码是一样,没有使用其它样式固定,搞的我莫名其妙。还以为是某个标签没有关闭,但是页面比较长,检查起来又嫌累,但是想来想去找不到其它原因,索性把浏览器一关,做别的事情去了。
重新打开这个页面的时候,突然发现那个链接的a:hover效果又出来了。我想了一下,点了那个链接,然后回过头再点,果然又没了。连忙检查css文档,发现a:hover属性写在了visited之前,改写到之后,重试,ok!
以前看书的时候注意到css中关于链接表现的书写有提示说各属性顺序不能颠倒,一直没有注意,写的时候通常都很随意。现在看来不能这个顺序还是很重要的。
css中关于超链接的四个属性一般正常顺序为:link,visited,hover,active

让火狐和IE里面的flash背景都透明透明

四月 16, 2009 作者:fangds   类别:HTML 已经有441次浏览

在IE浏览器中,我们只要在FLASH的属性里面加一个<param name=”wmode” value=”transparent” />就可以让FLASH的背景透明了,但是火狐里面似乎不起作用。查找了不少时间,发现问题所在。

下面的插入FLASH的代码可以解决这个问题,注册红色的部分,再看看你的,是不是少了后面的。

<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0″ width=”825″ height=”660″>
            <param name=”movie” value=”zhiye.swf” />
            <param name=”quality” value=”high” />
            <param name=”wmode” value=”transparent” />
            <embed src=”zhiye.swf” quality=”high” pluginspage=”http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash” type=”application/x-shockwave-flash” width=”825″ height=”660″  wmode=”transparent”></embed>
</object>

3个步骤来实现asp模块化分页

四月 13, 2009 作者:FDS   类别:ASP 已经有373次浏览

 通过3个步骤来实现模块化分页,1、查询语句块,2、显示记录块,3、输出分页效果

1、查询语句块

<%
取得当前文件名
temp = Split(request.ServerVariables(“URL”), “/”)
fy = temp(UBound(temp))
set rs=server.createobject(“adodb.recordset”)
if not isempty(request(“page”)) then  
pagecount=cint(request(“page”))  
else  
pagecount=1  
end if
sql=”select  查询语句”
rs.open sql,conn,1,1
rs.pagesize=10  分页记录数
if pagecount>rs.pagecount or pagecount<=0 then             
pagecount=1             
end if            
if rs.eof and rs.bof then%>

<div align=”center” class=”001″><br>
对不起,没有符合搜索条件的记录!<br>
</div>

2、显示记录块

<%
else
rs.AbsolutePage=pagecount
do while not rs.eof %>

显示的记录

<% i=i+2                                                                                                 
rs.movenext                                                                                                 
if i>=rs.PageSize then exit do
loop                                                                   
%>

3、输出分页效果
<table width=”778″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>
  <tr align=”center”>
    <% if rs.pagecount=1 then %>
    <td height=”35″ colspan=”4″ class=001><font color=”#000000″>共有[<font color="#ff0000"><%=rs.recordcount%></font>]条信息 当前显示第 <font color=”red”>1~<%=rs.recordcount%></font>条</font></td>
  </tr>
  <tr>
    <%else%>
    <td width=”19%” height=”35″ align=”center” valign=”middle” class=001><font color=”#000000″>
      <% page_start=(pagecount-1)*rs.pagesize
            if pagecount=1 then page_start=1
      page_end=rs.pagesize*pagecount
      if pagecount*rs.pagesize=>rs.recordcount then page_end=rs.recordcount end if%>
      共有[<font color="#ff0000"><%=rs.recordcount%></font>]信息</font></td>
    <td width=”58%” height=”30″ align=”center” class=”fy”><font color=”#000000″>
          <%
    if pagecount>5 and pagecount< rs.PageCount-5 and rs.pagecount>10 then
    qizu=pagecount-4
    min=pagecount+5
    response.write “<a href=”&source&”?page=1&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&title=”&title&”&cityid=”&cityid&”><font color=’0000BE’>首页</font></a>&nbsp;”
    response.write “<a href=”&source&”?page=”+cstr(pagecount-1)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&title=”&title&”&cityid=”&cityid&”><font color=’0000BE’>上一页</font></a>&nbsp;”                                                    
    for ipage=qizu to min
             if ipage<>pagecount then
             response.write “<a href=”&source&”?page=”+cstr(ipage)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&cityid=”&cityid&”><font color=’0000BE’>”+cstr(ipage)+”</font></a>&nbsp;”
             else
             response.write “<font color=’#FF0000′>”&ipage&”</font> “                                               
             end if
    next
    response.write “<a href=”&source&”?page=”+cstr(pagecount+1)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&title=”&title&”&cityid=”&cityid&”><font color=’0000BE’>下一页</font></a>&nbsp;”
    response.write “<a href=”&source&”?page=”+cstr(rs.PageCount)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&title=”&title&”&cityid=”&cityid&”><font color=’0000BE’>尾页</font></a>”
    end if
    if rs.PageCount<11 then
    for ipage=1 to rs.PageCount
             if ipage<>pagecount then
             response.write “<a href=”&source&”?page=”+cstr(ipage)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&cityid=”&cityid&”><font color=’0000BE’>”+cstr(ipage)+”</font></a>&nbsp;”
             else
             response.write “<font color=’#FF0000′>”&ipage&”</font> “                                               
             end if
    next
    end if
    if pagecount < 6 and rs.PageCount>10 then
    for ipage=1 to 10
             if ipage<>pagecount then
             response.write “<a href=”&source&”?page=”+cstr(ipage)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&cityid=”&cityid&”><font color=’0000BE’>”+cstr(ipage)+”</font></a>&nbsp;”
             else
             response.write “<font color=’#FF0000′>”&ipage&”</font> “                                               
             end if
    next
    response.write “<a href=”&source&”?page=”+cstr(rs.PageCount)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&title=”&title&”&cityid=”&cityid&”><font color=’0000BE’>尾页</font></a>”
    end if
    if pagecount>rs.PageCount-6 and rs.PageCount>10 then
    response.write “<a href=”&source&”?page=1&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&title=”&title&”&cityid=”&cityid&”><font color=’0000BE’>首页</font></a>&nbsp;”  
    for ipage=rs.PageCount-9 to rs.PageCount
             if ipage<>pagecount then
             response.write “<a href=”&source&”?page=”+cstr(ipage)+”&sortid=”&sortid&”&typeid=”&typeid&”&qylb=”&qylb&”&cityid=”&cityid&”><font color=’0000BE’>”+cstr(ipage)+”</font></a>&nbsp;”
             else
             response.write “<font color=’#FF0000′>”&ipage&”</font> “                                               
             end if
    next
    end if
             %>
    </font></td><form name=go2to form method=Post action=<%=fy%>> 
    <td width=”13%” align=”center” valign=”middle” class=”fy”>                                         
   <input type=’hidden’ name=’sortid’ value=”<%=sortid%>”><input type=’hidden’ name=’typeid’ value=”<%=typeid%>”><input type=’hidden’ name=’qylb’ value=”<%=qylb%>”><input type=’hidden’ name=’title’ value=”<%title%>”><input type=’hidden’ name=’cityid’ value=”<%=cityid%>”><font color=’000064′> 转到第<input type=’text’ name=’page’ size=2 maxLength=3>
   页</font>                              
   </td>
    <td width=”10%” align=”center” valign=”middle” class=”fy”><input name=”image” type=’image’ onClick=check() value=’确 定’ src=’http://edu.chinaz.com/Get/Program/images/button_h.jpg’></td>
    </form>
  <tr>
    <td height=”20″ colspan=”6″ valign=”bottom”><font color=”#000000″>&nbsp; </font></td>
  </tr>
  <% end if %>
  <% end if %>
</table>

用ASP实现在服务器自动在线解压RAR文件

四月 2, 2009 作者:FDS   类别:ASP 已经有437次浏览

文件打包以后,在服务器自动在线解压RAR文件,这样可以大量的减少上传文件的时间。也很方便!这里分享一个用ASP实现在服务器自动在线解压RAR文件的方法。

<%

dim ylj,ywj,Mlpath,Shell,rarcomm,RetCode,cmd,comm,fso

Mlpath=”E:\page\mian\”    ‘存放RAR.EXE和CMD.EXE的路径

ylj=Server.mappath(“mian”)&”\”  ‘解压文件后所放的路径

ywj=Server.mappath(“mian\apathy.rar”)  ‘要解压的RAR文件

Set Shell = Server.CreateObject(“WScript.Shell”)

rarcomm= “E:\page\mian\cmd.exe /c “&Mlpath&”rar.exe x -t -o+ -p- ”

cmd=rarcomm&ywj&” “&ylj

RetCode = Shell.Run(cmd,1, True)

%>

就是用Server.CreateObject(“WScript.Shell”)来执行CMD.EXE来运行RAR.EXE文件来解压RAR文件的。