首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-02-29 
为什么我的js代码没有起到效果%@ Master LanguageC# AutoEventWireuptrue CodeFileMasterPage.ma

为什么我的js代码没有起到效果
<%@ 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页中就行。这个是什么原因啊。


[解决办法]
你的对象方法不对吧!
[解决办法]
changeImages()
这个函数你有接收参数么?
有没有错,调试哇

[解决办法]
<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" />

热点排行