标题:这段代码在IE6中字幕能正常滚动,但在IE7,IE8,火狐中滚动字幕却不能显示或不 ...
只看楼主
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
结帖率:87.5%
已结贴  问题点数:20 回复次数:2 
这段代码在IE6中字幕能正常滚动,但在IE7,IE8,火狐中滚动字幕却不能显示或不能滚动?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../Connections/pqtep.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_pqtep_STRING
Recordset1.Source = "SELECT *  FROM tjqy  ORDER BY gd ASC, id ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim HLooper1__numRows
HLooper1__numRows = -1
Dim HLooper1__index
HLooper1__index = 0
Recordset1_numRows = Recordset1_numRows + HLooper1__numRows
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
a:link {
    text-decoration: none;
    color: #FFFFFF;
}
a:visited {
    text-decoration: none;
    color: #FFFFFF;
}
a:hover {
    text-decoration: none;
    color: #FFCC00;
}
a:active {
    text-decoration: none;
    color: #FFFFFF;
}
.style14 {
    font-size: 12px;
    color: #FFFFFF;
}
-->
</style>
</head>

<body>
<table width="236" height="251" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="middle" background="../../images/bg00000.jpg" bgcolor="#FFFFFF"><div  id="marquees"> <!-- 这些是字幕的内容,你可以任意定义 -->
        <%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
        <table width="220" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="18" height="18" align="left"><img src="15.gif" width="10" height="10" border="0"></td>
            <td width="202" align="left" valign="middle"><span class="style14"><a href="<%=(Recordset1.Fields.Item("url").Value)%>" target="_blank"><%=(Recordset1.Fields.Item("title").Value)%></a></span></td>
          </tr>
          </table>
        <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
<br>
      <!-- 字幕内容结束 -->
</div>
<!-- 以下是javascript代码 -->
<script language="javascript">
<!--
marqueesHeight=230; //内容区高度
stopscroll=false; //这个变量控制是否停止滚动
with(marquees){
noWrap=true; //这句表内容区不自动换行
style.width=0; //于是我们可以将它的宽度设为0,因为它会被撑大
style.height=marqueesHeight;
style.overflowY="hidden"; //滚动条不可见
onmouseover=new Function("stopscroll=true"); //鼠标经过,停止滚动
onmouseout=new Function("stopscroll=false"); //鼠标离开,开始滚动
}
//这时候,内容区的高度是无法读取了。下面输出一个不可见的层"templayer",稍后将内容复制到里面:
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
function init(){ //初始化滚动内容
//多次复制原内容到"templayer",直到"templayer"的高度大于内容区高度:
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
} //把"templayer"的内容的“两倍”复制回原内容区:
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
//设置连续超时,调用"scrollUp()"函数驱动滚动条:
setInterval("scrollUp()",20);
}
document.body.onload=init;
preTop=0; //这个变量用于判断滚动条是否已经到了尽头
function scrollUp(){ //滚动条的驱动函数
if(stopscroll==true) return; //如果变量"stopscroll"为真,则停止滚动
preTop=marquees.scrollTop; //记录滚动前的滚动条位置
marquees.scrollTop+=1; //滚动条向下移动一个像素
//如果滚动条不动了,则向上滚动到和当前画面一样的位置
//当然不仅如此,同样还要向下滚动一个像素(+1):
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight+1;
}
}
-->
</script></td>
  </tr>
</table>

<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
搜索更多相关主题的帖子: 火狐 字幕 滚动 代码 
2010-07-20 21:23
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
得分:20 
程序代码:
<style>
.dhMarquee {width:100px;height:100px;text-align:left;margin:0px;padding:0px;border:1px solid #000;overflow:hidden;white-space:nowrap;} 
.mqdemo {margin:0px;padding:0px;border:0px;}
.dhScrollA {font-size:12px;display:block;padding:2px;}
</style> 
<div id="mq" class="dhMarquee" onmouseover="iScrollAmount=0" onmouseout="iScrollAmount=1">
<div id="mqdemo" class="mqdemo">
<a class="dhScrollA" href="javascript:alert('1')">月圆之夜</a>
<a class="dhScrollA" href="javascript:alert('2')">紫禁之颠</a>
<a class="dhScrollA" href="javascript:alert('3')">西门吹雪</a>
<a class="dhScrollA" href="javascript:alert('4')">天外飞仙</a>
</div>
</div>
<script language="javascript"> 
var speed = 90; 
//滚动对象 
var oMarquee = document.getElementById("mq");
//内容对象 
var omqdemo = document.getElementById("mqdemo");
var w = oMarquee.offsetHeight;
var odl = omqdemo.offsetHeight;
var x = parseInt(w/odl)+1;
for(var i=0;i<x;i++){

 var o = omqdemo.cloneNode(true);

 oMarquee.appendChild(o);
}
var iScrollAmount = 1
function scroll(){

 oMarquee.scrollTop += iScrollAmount;

 var ol = oMarquee.scrollTop;

 if(odl-ol<=0){
  oMarquee.scrollTop = 0;

 }
}
var MyMar = window.setInterval(scroll,speed); 
</script>


参考一下这个吧,兼容多种浏览器,而且简单,自己改改CSS就能改变外观!

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-07-21 00:58
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
得分:0 
回复 2楼 gupiao175
非常感谢!
2010-07-21 04:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-313541-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.192179 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved