<%@ Page Language="C#" AutoEventWireup="true" CodeFile="副本 index.aspx.cs" Inherits="the_Final_index" %><!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 language="javascript">
function mouseOver()
{
[color=#00FF00]document.getElementById('Image1').ImageUrl="~/the Final/PIC/pic.jpg"}
</script>[/color]
<link href="CSS/1.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<table width="198" height="74" border="0">
<tr>
<td class="STYLE1"></td>
</tr>
</table>
</div>
<br />
<br />
<div>
<table width="1100" height="450" align="center" class="STYLE2" >
<tr>
<td colspan="3" rowspan="3" style="height: 164px"><table width="550" height="354" border="0" align="center" cellspacing="10">
<tr>
<td width="170" height="161" >
<a href="http://www.sina.com.cn" onmouseover="mouseOver()"><asp:Image ID="Image1" runat="server" Height="160px" ImageUrl="~/the Final/PIC/pic-0.jpg"
Width="170px" />
</a>
</td>
<td width="170" background="PIC/pic1.jpg" > </td>
<td width="170" background="PIC/pic2.jpg" > </td>
</tr>
<tr>
<td height="160" background="PIC/pic3.jpg" > </td>
<td background="PIC/pic4.jpg" > </td>
<td background="PIC/pic5.jpg" > </td>
</tr>
</table></td>
</tr>
</table>
</div>
</form>
</body>
</html>如上代码...能这样嵌套JS的语句么?但是黄色部分却拿不到路径...怎么改呢?请大家指教啊~
<head runat="server">
<title></title>
<script language="javascript">
function mouseOver()
{
[color=#00FF00]document.getElementById('Image1').ImageUrl="~/the Final/PIC/pic.jpg"}
</script>[/color]
<link href="CSS/1.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<table width="198" height="74" border="0">
<tr>
<td class="STYLE1"></td>
</tr>
</table>
</div>
<br />
<br />
<div>
<table width="1100" height="450" align="center" class="STYLE2" >
<tr>
<td colspan="3" rowspan="3" style="height: 164px"><table width="550" height="354" border="0" align="center" cellspacing="10">
<tr>
<td width="170" height="161" >
<a href="http://www.sina.com.cn" onmouseover="mouseOver()"><asp:Image ID="Image1" runat="server" Height="160px" ImageUrl="~/the Final/PIC/pic-0.jpg"
Width="170px" />
</a>
</td>
<td width="170" background="PIC/pic1.jpg" > </td>
<td width="170" background="PIC/pic2.jpg" > </td>
</tr>
<tr>
<td height="160" background="PIC/pic3.jpg" > </td>
<td background="PIC/pic4.jpg" > </td>
<td background="PIC/pic5.jpg" > </td>
</tr>
</table></td>
</tr>
</table>
</div>
</form>
</body>
</html>如上代码...能这样嵌套JS的语句么?但是黄色部分却拿不到路径...怎么改呢?请大家指教啊~
额 这个是黄色部分- -!
<asp:Image ID="Image1" runat="server" Height="160px" ImageUrl="~/the Final/PIC/pic-0.jpg" Width="170px" />
改为:
<img src="the Final/PIC/pic-0.jpg" height="160px" id="image1"/>
注意图片路径这两部分改一下:
<script language="javascript">
function mouseOver()
{
document.getElementById('Image1').ImageUrl="~/the Final/PIC/pic.jpg";
}
</script>
<a href="http://www.sina.com.cn" onmouseover="mouseOver()"> <asp:Image ID="Image1" runat="server" Height="160px" ImageUrl="~/the Final/PIC/pic-0.jpg"
Width="170px" />
</a>
改为:
<script language="javascript">
function mouseOver()
{
document.getElementById('Image1').src="the Final/PIC/pic.jpg"; //注意路径
}
</script> <a href="http://www.sina.com.cn" >
<img src="the Final/PIC/pic-0.jpg" height="160px" id="image1" onmouseover="mouseOver()"/>
</a>
在ASP.net中,会为各个服务器控件自动生成一个唯一的ClientId,ClientId值是通过连接
控件的ID值和父控件的UNIQUID值生成的,生成的ID的各个部分以下划线字符"_"分隔。
如:父控件名_image1
所以.net服务端控件,在客户端的ID名与所取的ID值是不相同的,
直接这样取:document.getElementById('Image1')是取不到的
ImageUrl属性(服务器属性)在客房端应对应img中的src属性
其实你这个效果不用这么复杂,直接这样写就行:<asp:Image ID="Image1" runat="server" Height="160px" ImageUrl="~/the Final/PIC/pic-0.jpg"
onmouseover="this.src='/the Final/PIC/pic.jpg';" onmouseout="this.src='/the Final/PIC/pic-0.jpg';" Width="170px" />
<asp:image id="Image1" runat="server" Width="140" Height="190" ImageUrl="images/user.gif"></asp:image><
这个是C#的用法
你用js是取不到绝对路径的
你要么用相对路径
要么用C#吧“"~/the Final/PIC/pic.jpg"”转成绝对路径如 ....src=<%= Page.sXXXUrl(""~/the Final/PIC/pic.jpg"") %>
汗,那个单词忘记怎么写了,自己点出来就知道了