如果我停留在我的默认页面上然后显示图像,但是当我继续浏览另一页图像时,我已将此放在我的MasterPage中。你能帮我解释为什么这不适用于另一页。
<ul id="scroller">
<div class="serv"> <a href="#" onmouseover="document.wordpress.src='images/wordpress-development_red.png'" onmouseout="document.wordpress.src='images/wordpress-development.png'"> <img src="images/wordpress-development.png" name="wordpress"><br />
WORDPRESS </a>
</div>
<div class="serv1"> <a href="#" onmouseover="document.Android.src='images/mobil-app-development_red.png'" onmouseout="document.Android.src='images/mobil-app-development.png'"> <img src="images/mobil-app-development.png" name="Android"/><br />
Android</a>
</div>
</ul>
答案 0 :(得分:7)
我怀疑你的形象的网址是错误的。既然你已经对其进行了硬编码,那就不足为奇了。您应该从不在ASP.NET MVC应用程序中硬编码URL。您应始终使用网址助手:
<a href="#" onmouseover="document.wordpress.src='@Url.Content("~/images/wordpress-development_red.png")'" onmouseout="document.wordpress.src='@Url.Content("~/images/wordpress-development.png")'">
<img src="@Url.Content("~/images/wordpress-development.png")" name="wordpress">
<br />
WORDPRESS
</a>
如果您使用的是WebForms视图引擎(请正确标记您的问题,以便我们不必猜测):
<a href="#" onmouseover="document.wordpress.src='<%= Url.Content("~/images/wordpress-development_red.png") %>'" onmouseout="document.wordpress.src='<%= Url.Content("~/images/wordpress-development.png") %>'">
<img src="<%= Url.Content("~/images/wordpress-development.png") %>" name="wordpress">
<br />
WORDPRESS
</a>