为什么我的js代码没有起到效果

赢光小虾米 2008-04-16 01:50:35
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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 runat="server">
<title></title>
<script type="text/javascript">
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
Button1_over = newImage("images/Button1-over.gif");
Button2_over = newImage("images/Button2-over.gif");
Button3_over = newImage("images/Button3-over.gif");
Button4_over = newImage("images/Button4-over.gif");
Button5_over = newImage("images/Button5-over.gif");
Shopping_cart_over = newImage("images/Shopping-cart-over.gif");
Button6_over = newImage("images/Button6-over.gif");
Button7_over = newImage("images/Button7-over.gif");
preloadFlag = true;
}
}
</script>
</head>
<body topmargin ="0" leftmargin ="0" rightmargin ="0">
<center>
<form id="form1" runat="server">
<div id="MainContent" style ="width:100%;"><!--总的框架-->
<div><!--头部的框架-->
<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><!--DWLayoutTable-->
<TR>
<TD COLSPAN=3 ROWSPAN=3 background="images/layout_34.gif" valign="top">
<IMG SRC="images/layout_01.gif" WIDTH=375 HEIGHT=76 ALT=""></TD>
<TD COLSPAN=6 ROWSPAN=5>
<IMG SRC="images/layout_02.gif" WIDTH=173 HEIGHT=107 ALT=""></TD>
<TD COLSPAN=2>
<A HREF="#"
onmouseover="changeImages('Button1', 'images/Button1-over.gif'); return true;"
onmouseout="changeImages('Button1', 'images/Button1.gif'); return true;">
<IMG NAME="Button1" SRC="images/Button1.gif" WIDTH=182 HEIGHT=27 BORDER=0 ALT=""></A></TD>
<TD COLSPAN=2 ROWSPAN=11 background="images/layout_04.gif">
<IMG SRC="images/layout_04.gif" WIDTH=30 HEIGHT=319 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=27 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2>
<A HREF="#"
ONMOUSEOVER="changeImages('Button2', 'images/Button2-over.gif'); return true;"
ONMOUSEOUT="changeImages('Button2', 'images/Button2.gif'); return true;">
<IMG NAME="Button2" SRC="images/Button2.gif" WIDTH=182 HEIGHT=31 BORDER=0 ALT=""></A></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=31 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2 ROWSPAN=2>
<A HREF="#"
ONMOUSEOVER="changeImages('Button3', 'images/Button3-over.gif'); return true;"
ONMOUSEOUT="changeImages('Button3', 'images/Button3.gif'); return true;">
<IMG NAME="Button3" SRC="images/Button3.gif" WIDTH=182 HEIGHT=31 BORDER=0 ALT=""></A></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=18 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2 ROWSPAN=6>
<IMG SRC="images/layout_07.gif" WIDTH=319 HEIGHT=137 ALT=""></TD>
<TD ROWSPAN=6>
<IMG SRC="images/layout_08.gif" WIDTH=56 HEIGHT=137 ALT=""></TD>
<TD style="height: 13px">
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=13 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2 ROWSPAN=2>
<A HREF="#"
ONMOUSEOVER="changeImages('Button4', 'images/Button4-over.gif'); return true;"
ONMOUSEOUT="changeImages('Button4', 'images/Button4.gif'); return true;">
<IMG NAME="Button4" SRC="images/Button4.gif" WIDTH=182 HEIGHT=31 BORDER=0 ALT=""></A></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=18 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=6 ROWSPAN=6>
<IMG SRC="images/layout_10.gif" WIDTH=173 HEIGHT=212 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=13 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2>
<A HREF="#"
ONMOUSEOVER="changeImages('Button5', 'images/Button5-over.gif'); return true;"
ONMOUSEOUT="changeImages('Button5', 'images/Button5.gif'); return true;">
<IMG NAME="Button5" SRC="images/Button5.gif" WIDTH=182 HEIGHT=31 BORDER=0 ALT=""></A></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=31 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2>
<A HREF="#"
ONMOUSEOVER="changeImages('Shopping_cart', 'images/Shopping-cart-over.gif'); return true;"
ONMOUSEOUT="changeImages('Shopping_cart', 'images/Shopping-cart.gif'); return true;">
<IMG NAME="Shopping_cart" SRC="images/Shopping-cart.gif" WIDTH=182 HEIGHT=40 BORDER=0 ALT=""></A></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=40 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2>
<A HREF="#"
ONMOUSEOVER="changeImages('Button6', 'images/Button6-over.gif'); return true;"
ONMOUSEOUT="changeImages('Button6', 'images/Button6.gif'); return true;">
<IMG NAME="Button6" SRC="images/Button6.gif" WIDTH=182 HEIGHT=22 BORDER=0 ALT=""></A></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=22 ALT=""></TD>
</TR>

</TABLE>
</div>
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
<div><!--尾部的框架-->
您是第<asp:PlaceHolder ID ="ph1" runat="server"></asp:PlaceHolder>
位访问者<br />
您是今天第<asp:PlaceHolder ID="ph2" runat="server"></asp:PlaceHolder>
位访问者<br />
</div>
</div>
</form>
</center>
</body>
</html>
为什么我的js代码没有起到效果,是不是js代码有错啊,我想实现当按钮移动上去是另个图片,移走是一张图片的效果。为什么不行啊。在Html页中就行。这个是什么原因啊。
...全文
120 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuyiazl 2008-04-16
  • 打赏
  • 举报
回复
<script language="javascript">
var img = function(obj,img){
obj.src = img;
}
</script>



<img onmousemove="img(this,'jquery/face/1.gif')" onmouseout="img(this,'jquery/face/38.gif')" src="jquery/face/38.gif" />
fancystyle 2008-04-16
  • 打赏
  • 举报
回复
changeImages()
这个函数你有接收参数么?
有没有错,调试哇
jingkunli 2008-04-16
  • 打赏
  • 举报
回复
你的对象方法不对吧!

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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