初学求教: Javescript 代码这样输出行吗?

Ctoyun 2007-06-10 12:05:26
我有一段完整的 Javascript 代码,是一段能够向上间歇滚动的文字,我想把它放在表格中单元格使用,请问这样写行吗?还有其它好办法吗?(我要用整个 Javascript 部分,不是其中的函数)


<td><script langauge="javascript">... 这里是 Javascript 代码内容 ... </script>
</td>


谢谢!
...全文
328 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
TopFans 2007-06-11
  • 打赏
  • 举报
回复
好长啊
帮顶!!
tony-杨 2007-06-11
  • 打赏
  • 举报
回复
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
<!--
/********************************/
/* 文字自动循环滚动 */
/* Power by Todd Lee */
/* lijiantao@eyou.com */
/* www.todd-lee.com */
/* IE6 FF1.0.4 */
/* 不支持xhtml声明的文档 */
/* 2005-05-24 v1.0 */
/********************************/

//*********不要修改这部分***************
//scrollBodyId: String 内部滚动div的id
//scrollBoxId: String 外面限制div的id
//showHeight: Int 限制显示高度
//showWidth: Int 限制显示宽度
//lineHeight: Int 每行的高度
//stopTime: Int 间隔停止的时间(毫秒)
//speed: Int 滚动速度(毫秒,越小越快)
var ScrollObj = function(scrollBodyId,scrollBoxId,showHeight,showWidth,lineHeight,stopTime,speed) {
this.obj = document.getElementById(scrollBodyId);
this.box = document.getElementById(scrollBoxId);

this.style = this.obj.style;
this.defaultHeight = this.obj.offsetHeight;

this.obj.innerHTML += this.obj.innerHTML;
this.obj.style.position = "relative";

this.box.style.height = showHeight;
this.box.style.width = showWidth;
this.box.style.overflow = "hidden";

this.scrollUp = doScrollUp;

this.stopScroll = false;

this.curLineHeight = 0;
this.lineHeight = lineHeight;
this.curStopTime = 0;
this.stopTime = stopTime;
this.speed = speed;

this.style.top = lineHeight;

this.object = scrollBodyId + "Object";
eval(this.object + "=this");
setInterval(this.object+".scrollUp()",speed);
this.obj.onmouseover=new Function(this.object+".stopScroll=true");
this.obj.onmouseout=new Function(this.object+".stopScroll=false");
}
function doScrollUp(){
if( this.stopScroll == true )
return;
this.curLineHeight += 1;
if( this.curLineHeight >= this.lineHeight ){
this.curStopTime += 1;
if( this.curStopTime >= this.stopTime ){
this.curLineHeight = 0;
this.curStopTime = 0;
}
}
else{
this.style.top = parseInt(this.style.top) - 1;
if( -parseInt(this.style.top) >= this.defaultHeight ){
this.style.top = 0;
}
}
}
//***************这以上不要修改******************
//-->
</script>
</head>

<body>
<div id="scroollBox" style="border:1px solid red; ">
<div id="scroollBody">
这里是一些提示信息<br>
他可以自动向上循环的滚动<br>
每滚动一行,就会停下来休息一会<br>
当鼠标经过他的时候,他停止滚动<br>
当鼠标离开时,他继续滚动<br>
</div>
</div>
<script language="javascript" type="text/javascript">
<!--
var sample = new ScrollObj("scroollBody","scroollBox",36,300,19,50,50);
// -->
</script>
</body>
</html>
tony-杨 2007-06-11
  • 打赏
  • 举报
回复
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文字自动循环滚动</title>
<script language='javascript'>
<!--
/********************************/
/* 文字自动循环滚动 */
/* Power by Todd Lee */
/* lijiantao@eyou.com */
/* IE6 FF1.0.4 */
/* 不支持xhtml声明的文档 */
/* 2005-05-24 v1.0 */
/********************************/

//*********不要修改这部分***************
//scrollBodyId: String 内部滚动div的id
//scrollBoxId: String 外面限制div的id
//showHeight: Int 限制显示高度
//showWidth: Int 限制显示宽度
//lineHeight: Int 每行的高度
//stopTime: Int 间隔停止的时间(毫秒)
//speed: Int 滚动速度(毫秒,越小越快)
var ScrollObj = function(scrollBodyId,scrollBoxId,showHeight,showWidth,lineHeight,stopTime,speed) {
this.obj = document.getElementById(scrollBodyId);
this.box = document.getElementById(scrollBoxId);

this.style = this.obj.style;
this.defaultHeight = this.obj.offsetHeight;

this.obj.innerHTML += this.obj.innerHTML;
this.obj.style.position = "relative";

this.box.style.height = showHeight;
this.box.style.width = showWidth;
this.box.style.overflow = "hidden";

this.scrollUp = doScrollUp;

this.stopScroll = false;

this.curLineHeight = 0;
this.lineHeight = lineHeight;
this.curStopTime = 0;
this.stopTime = stopTime;
this.speed = speed;

this.style.top = lineHeight;

this.object = scrollBodyId + "Object";
eval(this.object + "=this");
setInterval(this.object+".scrollUp()",speed);
this.obj.onmouseover=new Function(this.object+".stopScroll=true");
this.obj.onmouseout=new Function(this.object+".stopScroll=false");
}
function doScrollUp() {
if( this.stopScroll == true )
return;
this.curLineHeight += 1;
if( this.curLineHeight >= this.lineHeight ) {
this.curStopTime += 1;
if( this.curStopTime >= this.stopTime ) {
this.curLineHeight = 0;
this.curStopTime = 0;
}
}
else {
this.style.top = parseInt(this.style.top) - 1;
if( -parseInt(this.style.top) >= this.defaultHeight ) {
this.style.top = 0;
}
}
}
//***************这以上不要修改******************
//-->
</script>
</head>

<body>
<div id="scroollBox" style="border:1px solid #f00; ">
<div id="scroollBody">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td><img name="test1" src="" width="100" height="100" alt="" style="background-color: #FF0000"></td>
<td><img name="test2" src="" width="100" height="100" alt="" style="background-color: #FFFF00"></td>
<td><img name="test3" src="" width="100" height="100" alt="" style="background-color: #99FF00"></td>
<td><img name="test4" src="" width="100" height="100" alt="" style="background-color: #0099FF"></td>
<td><img name="test5" src="" width="100" height="100" alt="" style="background-color: #660099"></td>
</tr>
<tr>
<td><img name="test1" src="" width="100" height="100" alt="" style="background-color: #FF0000"></td>
<td><img name="test2" src="" width="100" height="100" alt="" style="background-color: #FFFF00"></td>
<td><img name="test3" src="" width="100" height="100" alt="" style="background-color: #99FF00"></td>
<td><img name="test4" src="" width="100" height="100" alt="" style="background-color: #0099FF"></td>
<td><img name="test5" src="" width="100" height="100" alt="" style="background-color: #660099"></td>
</tr>
</table>
</div>
</div>
<script language="javascript" type="text/javascript">
<!--
//var sample = new ScrollObj(String 内部滚动div的id, String 外面限制div的id, Int 限制显示高度, Int 限制显示宽度, Int 每行的高度, Int 间隔停止的时间(毫秒), Int 滚动速度(毫秒,越小越快));
var sample = new ScrollObj("scroollBody", "scroollBox", 110, 560, 111, 50, 10);
// -->
</script>
</body>
</html>
rjzou2006 2007-06-10
  • 打赏
  • 举报
回复
这个是完整代码

两个合起来的
rjzou2006 2007-06-10
  • 打赏
  • 举报
回复

if (slideimages.length>1)
i=2
else
i=0

function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.top>0&&tlayer.top<=5){
tlayer.top=0
setTimeout("move1(tlayer)",pausebetweenimages)
setTimeout("move2(document.main.document.second)",pausebetweenimages)
return
}
if (tlayer.top>=tlayer.document.height*-1){
tlayer.top-=5
setTimeout("move1(tlayer)",100)
}
else{
tlayer.top=scrollerheight
tlayer.document.write(slideimages[i])
tlayer.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
}

function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.top>0&&tlayer2.top<=5){
tlayer2.top=0
setTimeout("move2(tlayer2)",pausebetweenimages)
setTimeout("move1(document.main.document.first)",pausebetweenimages)
return
}
if (tlayer2.top>=tlayer2.document.height*-1){
tlayer2.top-=5
setTimeout("move2(tlayer2)",100)
}
else{
tlayer2.top=scrollerheight
tlayer2.document.write(slideimages[i])
tlayer2.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
}

function move3(whichdiv){
tdiv=eval(whichdiv)
if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){
tdiv.style.pixelTop=0
setTimeout("move3(tdiv)",pausebetweenimages)
setTimeout("move4(second2)",pausebetweenimages)
return
}
if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){
tdiv.style.pixelTop-=5
setTimeout("move3(tdiv)",100)
}
else{
tdiv.style.pixelTop=scrollerheight
tdiv.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}

function move4(whichdiv){
tdiv2=eval(whichdiv)
if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){
tdiv2.style.pixelTop=0
setTimeout("move4(tdiv2)",pausebetweenimages)
setTimeout("move3(first2)",pausebetweenimages)
return
}
if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){
tdiv2.style.pixelTop-=5
setTimeout("move4(second2)",100)
}
else{
tdiv2.style.pixelTop=scrollerheight
tdiv2.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}

function startscroll(){
if (document.all){
move3(first2)
second2.style.top=scrollerheight
}
else if (document.layers){
document.main.visibility='show'
move1(document.main.document.first)
document.main.document.second.top=scrollerheight+5
document.main.document.second.visibility='show'
}
}

window.onload=startscroll

</script>
</HEAD>
<body bgcolor="#efefef" ondblclick="HiddenMenu()" title="双击灰色区域可以 隐藏/显示 菜单项">
<form name="Form1" method="post" action="TopMenu.aspx" id="Form1">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="dDwtMTE1MTE4MjcyNTt0PDtsPGk8MD47PjtsPHQ8O2w8aTwxPjtpPDM+Oz47bDx0PHA8cDxsPFRleHQ7PjtsPOeuoeeQhuWRmDs+Pjs+Ozs+O3Q8dDxwPHA8bDxEYXRhVGV4dEZpZWxkO0RhdGFWYWx1ZUZpZWxkOz47bDxjb3JwX2NubTtjb3JwX25vOz4+Oz47dDxpPDE3PjtAPC0tLS0tLeivt+mAieaLqS0tLS0tLTvkuK3lsbHluILokYblipvniankuJrnrqHnkIbmnInpmZDlhazlj7g754+g5rW36JGG5Yqb5L+d5rSB5pyN5Yqh5pyJ6ZmQ5YWs5Y+4O+ePoOa1t+W4guiRhuWKm+S5i+aYn+eJqeS4mueuoeeQhuaciemZkOWFrOWPuDvkuJzojp7lrp3npaXniankuJrnrqHnkIbmnInpmZDlhazlj7g75piG5bGx5YWD5paw54mp5Lia566h55CG5pyJ6ZmQ5YWs5Y+4O+ePoOa1t+iRhuWKm+eJqeS4mueuoeeQhuaciemZkOWFrOWPuDvokYblipvniankuJrku6PnkIbpg6g754+g5rW36JGG5Yqb54mp5Lia566h55CG5pyJ6ZmQ5YWs5Y+45bm/5bee5YiG5YWs5Y+4O+ePoOa1t+iRhuWKm+eJqeS4mueuoeeQhuaciemZkOWFrOWPuOaYhuWxseWIhuWFrOWPuDvnj6DmtbfokYblipvniankuJrnrqHnkIbmnInpmZDlhazlj7jkuJzojp7liIblhazlj7g754+g5rW36JGG5Yqb54mp5Lia566h55CG5pyJ6ZmQ5YWs5Y+45Lit5bGx5YiG5YWs5Y+4O+ePoOa1t+iRhuWKm+aYjuWFieeJqeS4mueuoeeQhuaciemZkOWFrOWPuDvnj6DmtbfokYblipvniankuJrnrqHnkIbmnInpmZDlhazlj7jph43luobliIblhazlj7g754+g5rW36JGG5Y2O5Zut5p6X57u/5YyW5pyJ6ZmQ5YWs5Y+4O+ePoOa1t+WuneazsOeUteair+aciemZkOWFrOWPuDvokYbliptFUlDns7vnu5/mtYvor5Xlhazlj7g7PjtAPFxlOzY2UTs2NlI7NjZTOzY4Vzs2OFg7NjlWO0FHVDAxO0IwMEE7QjAzMjtCMDNKO0IwNkE7QjA2QjtCMDdJO0JIWUw7QlREVDtURVNUOz4+O2w8aTwwPjs+Pjs7Pjs+Pjs+Pjs+y/NP1An5nuMWWw7dSkL3SEIldgM=" />

<script language="javascript" type="text/javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
theform = document.Form1;
}
else {
theform = document.forms["Form1"];
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>

<FONT face="宋体">
<table width="100%">
<tr>
<td><span id="LUser" style="color:Maroon;">管理员</span>您好:<select name="DCorp" onchange="__doPostBack('DCorp','')" language="javascript" id="DCorp" class="input1">
<option selected="selected" value="">------请选择------</option>
<option value="66Q">中山市葆力物业管理有限公司</option>
<option value="66R">珠海葆力保洁服务有限公司</option>
<option value="66S">珠海市葆力之星物业管理有限公司</option>
<option value="68W">东莞宝祥物业管理有限公司</option>
<option value="68X">昆山元新物业管理有限公司</option>
<option value="69V">珠海葆力物业管理有限公司</option>
<option value="AGT01">葆力物业代理部</option>
<option value="B00A">珠海葆力物业管理有限公司广州分公司</option>
<option value="B032">珠海葆力物业管理有限公司昆山分公司</option>
<option value="B03J">珠海葆力物业管理有限公司东莞分公司</option>
<option value="B06A">珠海葆力物业管理有限公司中山分公司</option>
<option value="B06B">珠海葆力明光物业管理有限公司</option>
<option value="B07I">珠海葆力物业管理有限公司重庆分公司</option>
<option value="BHYL">珠海葆华园林绿化有限公司</option>
<option value="BTDT">珠海宝泰电梯有限公司</option>
<option value="TEST">葆力ERP系统测试公司</option>

</select></td>
<td align="center"><ilayer id="main" width="height=bgColor=visibility=hide">
<layer id="first" left="0" top="1" width="">
<script language="JavaScript">
if (document.layers)
document.write(slideimages[0])
</script>
</layer>
<layer id="second" left="0" top="0" width="visibility=hide">
<script language="JavaScript">
if (document.layers)
document.write(slideimages[1])
</script>
</layer>
</ilayer><script language="JavaScript">
if (document.all){
document.writeln('<span id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+'">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0">')
document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0;top:1;">')
document.write(slideimages[0])
document.writeln('</div>')
document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0;top:0">')
document.write(slideimages[1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</span>')
}
</script></td>
<td align="right">
<a id="LinkButton1" href="javascript:__doPostBack('LinkButton1','')">退出登录</a></td>
</tr>
</table>
</FONT>
</form>
</body>
</HTML>
rjzou2006 2007-06-10
  • 打赏
  • 举报
回复

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>TopMenu</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<style>TD { FONT-SIZE: 9pt }
.input1 { BORDER-RIGHT: #5699c0 1px solid; BORDER-TOP: #5699c0 1px solid; PADDING-LEFT: 5px; FONT-SIZE: 11px; BORDER-LEFT: #5699c0 1px solid; COLOR: #3c7ba2; BORDER-BOTTOM: #5699c0 1px solid; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"; HEIGHT: 18px; BACKGROUND-COLOR: #eff7ff }
</style>
<script language="javascript">
//var isHiddenMenu =false;
function HiddenMenu(){
parent.MidPage.SwitchBar();
}
function RefreshFramePage()
{
parent.LeftPage.document.location.href="UserMenu.aspx";
parent.RightPage.document.location.href="welcome.aspx";
//parent.RightPage.document.location.href="test.aspx";
}
</script>
<script language="JavaScript">
/*
Up down slideshow Script- Updated: 99/05/15
By Dynamic Drive (www.dynamicdrive.com)
For full source code, terms of use, and 100's more scripts, visit http://dynamicdrive.com
*/

///////configure the below four variables to change the style of the slider///////
//set the scrollerwidth and scrollerheight to the width/height of the LARGEST image in your slideshow!
var scrollerwidth=450
var scrollerheight=15
var scrollerbgcolor='#F6F6F6'
//3000 miliseconds=3 seconds
var pausebetweenimages=3000


//configure the below variable to change the images used in the slideshow. If you wish the images to be clickable, simply wrap the images with the appropriate <a> tag
var slideimages=new Array()
slideimages[0]='欢迎使用葆力物业管理ERP系统';
slideimages[1]='<font color=blue>注意:</font>公司总部人员请使用<a href="http://192.168.0.200/erp" target="_top">http://192.168.0.200/erp</a>来访问系统,以节省网络带宽';
slideimages[2]='<font color=red>New!</font><font color=red>注意:仓库每月月底必须进行月结,一级仓在每月最后一天和下月第一天月结</font>';
slideimages[3]='<font color=gray>续上条:</font><font color=red>二级库在每月6号前月结,否则不能出库</font>';
slideimages[4]='<font color=Green>系统有问题请发送邮件至Sunny@Baolee.com.cn(王弟建)</font>';
slideimages[5]='<font color=red>也可以发送至Knife@Baolee.com.cn(曹涛)</font>';
slideimages[6]='<font color=#006699>零用金1万元以上要在转账请款中请款,开户单位填写<font color=red>现金</font></font>';
slideimages[7]='系统转出的Excel表如需修改,则要另存为Excel工作簿格式';
slideimages[8]='<font color=gray>续上条:</font>点击查看:<a href="http://charge.baolee.com.cn/HELP/Update.htm#U7" target="_blank">如何另存Excel工作簿格式</a>';
slideimages[9]='最后更新时间:2007-06-09 09:30:26';

/*slideimages[0]='葆力物业管理ERP试运行';
slideimages[1]='<font color=#006699>目前有仓库采购、零用金、人事薪资已可以直接在网上操作</font>';
*/

//extend this list

///////Do not edit pass this line///////////////////////

87,921

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧