昨天在用ASP實現添加類似“QQ線上客服”功能的模組時遇到一個問題:功能基本上實現了但是對話方塊不跟著捲軸一起滾動,把代碼仔細研究之後終於發現問題了,哈哈、、、、 其實就出在第一行,在dreamweaver 8.0裡面直接建立一個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">,仔細對照下面的原始碼之後才知道問題就出在多了 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd",把它刪除就OK了。
下面的ASP代碼直接複製就可以運行:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>QQ線上客服代碼示範</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.3790.4186" name=GENERATOR></HEAD>
<BODY>
<DIV id=divStay style="POSITION: absolute">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top width="7%"> </TD></TR></TBODY></TABLE></DIV>
<SCRIPT language=javascript>
function picsize(obj,MaxWidth){
img=new Image();
img.src=obj.src;
if (img.width>MaxWidth)
{
return MaxWidth;
}
else
{
return img.width;
}
}
function CloseQQ()
{
divStayTopleft.style.display="none";
return true;
}
var online= new Array();
</SCRIPT>
<DIV id=divStayTopleft style="POSITION: absolute">
<TABLE cellSpacing=0 cellPadding=0 width=109 border=0>
<TBODY>
<TR>
<TD colSpan=3><A onclick=CloseQQ() href="javascript:;" shape=circle
coords=91,16,12><IMG height=34 src="index_files/qq_top.gif" width=109
useMap=#Map border=0></A></TD></TR>
<TR>
<TD width=6><IMG height=100 src="index_files/qq_life.gif" width=6></TD>
<TD vAlign=top width=96 background="">
<TABLE cellSpacing=0 cellPadding=0 width=90 align=center border=0>
<TBODY>
<TR>
<TD height=30>
<TABLE cellSpacing=0 cellPadding=0 width=90 border=0>
<TBODY>
<TR>
<TD><IMG height=13 src="index_files/qq_ico1.gif"
width=16><SPAN class=font_12> <SPAN
style="FONT-SIZE: 9pt">客戶服務</SPAN></SPAN></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD>
<TABLE id=table47 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top width=15 height=23><IMG height=16
src="index_files/qq_v01.gif" width=16 border=0></TD>
<TD vAlign=bottom>
<SCRIPT>document.write("<a target=blank href=tencent://message/?uin=178010108&Site=阿里西西&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:615050000:10 alt=[阿里西西]></a>");</SCRIPT>
</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD></TD></TR>
<TR>
<TD>
<TABLE id=table47 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top width=15 height=23><IMG height=16
src="index_files/qq_n01.gif" width=16 border=0></TD>
<TD vAlign=bottom>
<SCRIPT>document.write("<a target=blank href=tencent://message/?uin=178160088&Site=網頁特效&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:43486831:10 alt=[特效代碼]></a>");</SCRIPT>
</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD></TD></TR></TBODY></TABLE></TD>
<TD width=7><IMG height=100 src="index_files/qq_right.gif" width=7></TD></TR>
<TR>
<TD colSpan=3><IMG height=30 src="index_files/qq_bottom1.gif"
width=109></TD></TR>
<TR>
<TD colSpan=3><IMG height=33 src="index_files/qq_logo.gif"
width=109></TD></TR></TBODY></TABLE></DIV>
<SCRIPT type=text/javascript>
function FloatTop()
{
var startX1 =document.body.offsetWidth-125 ,startY1 = 5;
var startX2 =0,startY2 = 95;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id,startX,startY)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x;this.style.top=y;};
el.x = startX;
el.y = startY;
return el;
}
window.stayTopLeft=function()
{
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY1 - ftlObj.y)/8;
ftlObj1.y += (pY + startY2 - ftlObj1.y)/8;
ftlObj.sP(document.body.scrollLeft+document.body.offsetWidth-125, ftlObj.y);
ftlObj1.sP(ftlObj1.x, ftlObj1.y);
setTimeout("stayTopLeft()", 30);
}
// ftlObj = ml("divStay",document.body.scrollLeft+document.body.offsetWidth-125,0);
// ftlObj1 = ml("divStayTopLeft",0,30);
ftlObj = ml("divStay",(document.body.scrollLeft+document.body.offsetWidth)/2+379,0);
ftlObj1 = ml("divStayTopLeft",(document.body.scrollLeft+document.body.offsetWidth)/2+379,30);
stayTopLeft();
}
FloatTop();
</SCRIPT>
<!--End: QQ線上客服 -->
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P></P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P></P>
</BODY></HTML>