| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 602 人关注过本帖
标题:js不能正常显示
只看楼主 加入收藏
noodle
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-7-1
收藏
 问题点数:0 回复次数:2 
js不能正常显示

我有一段js代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01

Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;

charset=gb2312">
<title>menu</title>
<style type="text/css">
.titleStyle{
background-color:#008800;color:#ffffff;border-top:1px solid

#FFFFFF;font-size:9pt;cursor:hand;
}
.contentStyle{
background-color:#eeffee;color:blue;font-size:9pt;
}

a{
color:blue;
}
body{
font-size:9pt;
}
</style>
</head>

<body>
<script language="JavaScript">
<!--
var layerTop=20; //菜单顶边距
var layerLeft=30; //菜单左边距
var layerWidth=120; //菜单总宽
var titleHeight=20; //标题栏高度
var contentHeight=200; //内容区高度
var stepNo=10; //移动步数,数值越大移动越慢

var itemNo=0;runtimes=0;
document.write('<span id=itemsLayer

style="position:absolute;overflow:hidden;border:1px solid

#008800;left:'+layerLeft+';top:'+layerTop+';width:'+layerWidt

h+';">');

function addItem(itemTitle,itemContent){
itemHTML='<div id=item'+itemNo+' itemIndex='+itemNo+'

style="position:relative;left:0;top:'+(-

contentHeight*itemNo)+';width:'+layerWidth+';"><table

width=100% cellspacing="0" cellpadding="0">'+
'<tr><td height='+titleHeight+' onclick=changeItem

('+itemNo+') class="titleStyle"

align=center>'+itemTitle+'</td></tr>'+
'<tr><td height='+contentHeight+'

class="contentStyle">'+itemContent+'</td></tr></table></div>'

;
document.write(itemHTML);
itemNo++;
}
//添加菜单标题和内容,可任意多项,注意格式:
addItem('欢迎','<BR>  欢迎光临设计在线!');
addItem('美工教室','<center><a href="#">平面设计 </a>

<BR><BR><a href="#">三维空间</a> <BR><BR><a href="#">设计基础

</a> <BR><BR><a href="#">更多..</a></center>');
addItem('网页陶吧','<center><a href="#">网页工具</a>

<BR><BR><a href="#">技术平台</a> <BR><BR><a href="#">设计理念

</a> <BR><BR><a href="#">更多</a></center>');

addItem('Flash','<center><a href="#">基础教程</a> <BR><BR><a

href="#">技巧运用</a> <BR><BR><a href="#">实例剖析</a>

<BR><BR><a href="#">更多..</a></center>');
addItem('多媒体','<center><a href="#">DIRECTOR</a>

<BR><BR><a href="#">Authorware</a> <BR><BR><a href="#">更

多..</a></center>');
addItem('精品赏析','<center><a href="#">设计精品

</a></center>');

document.write('</span>')

document.all.itemsLayer.style.height=itemNo*titleHeight+conte

ntHeight;

toItemIndex=itemNo-1;onItemIndex=itemNo-1;

function changeItem(clickItemIndex){
toItemIndex=clickItemIndex;
if(toItemIndex-onItemIndex>0) moveUp(); else moveDown();
runtimes++;
if(runtimes>=stepNo){
onItemIndex=toItemIndex;
runtimes=0;}
else
setTimeout("changeItem(toItemIndex)",10);
}

function moveUp(){
for(i=onItemIndex+1;i<=toItemIndex;i++)
eval('document.all.item'+i+'.style.top=parseInt

(document.all.item'+i+'.style.top)-contentHeight/stepNo;');
}

function moveDown(){
for(i=onItemIndex;i>toItemIndex;i--)
eval('document.all.item'+i+'.style.top=parseInt

(document.all.item'+i+'.style.top)+contentHeight/stepNo;');
}
changeItem(0);
//-->
</script>
</body>
</html>
当我把它保存成.js时可以用浏览器打开,正常显示,但当我把它换成

.html或.jsp格式时用浏览器打开时却不能正常显示。
为什么?哪位大侠救救命啊?

搜索更多相关主题的帖子: blank content PUBLIC ffffff cursor 
2006-05-26 21:08
llingma
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2006-5-19
收藏
得分:0 
使用html或jsp时请把页面上需要显示的内容放在script外

2006-05-27 09:30
bagger
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:33
帖 子:891
专家分:0
注 册:2005-8-16
收藏
得分:0 
楼上说的对哦

【三元毕业设计论文】
三元论文真的只有三元钱
客服QQ:742670649
http://shop35094218./
2006-05-27 13:15
快速回复:js不能正常显示
数据加载中...
 
   



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

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