为什么控制图片大小的javascript代码没有生效?

rampart 2009-07-09 08:57:37
网上抄的,新闻图片幻灯浏览javascript实现代码,原代码为:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="JavaScript">
<!--
function objSP_Article()
{
this.ImgUrl=""; this.LinkUrl=""; this.Title="";
}
function SlidePic_Article(_id)
{
this.ID=_id;
this.Width=0;
this.Height=0;
this.TimeOut=5000;
this.Effect=23;
this.TitleLen=0;
this.PicNum=-1;
this.Img=null;
this.Url=null;
this.Title=null;
this.AllPic=new Array();
this.Add=SlidePic_Article_Add;
this.Show=SlidePic_Article_Show;
this.LoopShow=SlidePic_Article_LoopShow;
}
function SlidePic_Article_Add(_SP)
{
this.AllPic[this.AllPic.length] = _SP;
}
function SlidePic_Article_Show()
{
if(this.AllPic[0] == null)
return false;
document.write("<div align='center'><a id='Url_" + this.ID + "' href='' target='_blank' ><img id='Img_" + this.ID + "' style= 'width:" + this.Width + "; height:" + this.Height + "; filter: revealTrans(duration=2,transition=23);' src='javascript:null' border='0' ></a>");
if(this.TitleLen != 0)
document.write("<br><span id='Title_" + this.ID + "'></span></div>");
this.Img = document.getElementById("Img_" + this.ID);
this.Url = document.getElementById("Url_" + this.ID);
this.Title = document.getElementById("Title_" + this.ID);
this.LoopShow();
}
function SlidePic_Article_LoopShow() {
if(this.PicNum<this.AllPic.length-1)
this.PicNum++ ;
else
this.PicNum=0;
this.Img.filters.revealTrans.Transition=this.Effect;
this.Img.filters.revealTrans.apply();
this.Img.src=this.AllPic[this.PicNum].ImgUrl;
this.Img.filters.revealTrans.play();
this.Url.href=this.AllPic[this.PicNum].LinkUrl;
if(this.Title) this.Title.innerHTML="<a href="+this.AllPic[this.PicNum].LinkUrl+" target=_blank>"+this.AllPic[this.PicNum].Title+"</a>";
this.Img.timer=setTimeout(this.ID+".LoopShow()",this.TimeOut);
}
//-->
</script>
</head>

<body>
<script language="JavaScript">
var SlidePic = new SlidePic_Article("SlidePic");
SlidePic.Width = 158; //控制图片宽度,为什么没有生效?
SlidePic.Height = 128; //控制图片高度,为什么没有生效?
SlidePic.TimeOut = 5000;
SlidePic.Effect = 23;
SlidePic.TitleLen = 24;
var oSP = new objSP_Article();
oSP.ImgUrl = "001.jpg"; //图片的相对路径
oSP.LinkUrl = "NewsShow.aspx?logID=543&cateID=6";
oSP.Title = "我校“五一”国际劳动节升国旗";
SlidePic.Add(oSP);
var oSP = new objSP_Article();
oSP.ImgUrl = "002.jpg";
oSP.LinkUrl = "NewsShow.aspx?logID=543&cateID=6";
oSP.Title = "2006年学生工作总结大会举行";
SlidePic.Add(oSP);
var oSP = new objSP_Article();
oSP.ImgUrl = "003.jpg";
oSP.LinkUrl = "NewsShow.aspx?logID=543&cateID=6";
oSP.Title = "教育部领导来我院检查迎评工作";
SlidePic.Add(oSP);
SlidePic.Show();
</script>

</body>
</html>



新闻图片幻灯展示效果实现了,但图片大小没有改变,看了半天也没有看出来,哪位高手帮忙看一看,为什么控制图片大小的代码
“var SlidePic = new SlidePic_Article("SlidePic");
SlidePic.Width = 158; //控制图片宽度,为什么没有生效?
SlidePic.Height = 128; //控制图片高度,为什么没有生效?”没有生效?



为什么控制图片大小的javascript代码没有生效?
...全文
61 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
rampart 2009-07-10
  • 打赏
  • 举报
回复
多谢指点,终于发现错误所在,自已基本功实在惭愧。
浪尖赏花 2009-07-09
  • 打赏
  • 举报
回复
SlidePic_Article_Show()函数换成
function SlidePic_Article_Show() 
{
if(this.AllPic[0] == null)
return false;
document.write(" <div align='center'> <a id='Url_" + this.ID + "' href='' target='_blank' > <img id='Img_" + this.ID + "' style= 'width:" + this.Width + "px; height:" + this.Height + "px; filter: revealTrans(duration=2,transition=23);' src='javascript:null' border='0' > </a>");
if(this.TitleLen != 0)
document.write(" <br> <span id='Title_" + this.ID + "'> </span> </div>");
this.Img = document.getElementById("Img_" + this.ID);
this.Url = document.getElementById("Url_" + this.ID);
this.Title = document.getElementById("Title_" + this.ID);
this.LoopShow();
}
monexus 2009-07-09
  • 打赏
  • 举报
回复
SlidePic.Width = '158px';
SlidePic.Height = '128px';

87,901

社区成员

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

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