ASP MVC 3 - 图像未显示在首页视图上 - 但经常刷新
我见过很多关于图像不显示的问题,但我的问题似乎是间歇性的,通常图像不会出现在首页视图上,但会在刷新后出现。我正在使用 JQuery 插件在图像悬停时弹出一些文本。
这是一个 HTML 片段(实际上我有三张图像,但这里只添加了一张):
<div class="container_24 spacing-bot">
<ul id="topGallery" class="image-overlay">
<li>
<a href="@Url.Action("Index", "Wedding")">
<img src="@Url.Content("~/content/images/photos/image_one.png")" width="290" height="433" alt="Image One."/>
<div class="caption">
<h3>Heading One</h3>
<p>Pop up comment one.</p>
</div>
</a>
</li>
</ul>
页面底部的 JQuery 代码是:
$("#topGallery")
.ImageOverlay({
border_color: "#000",
overlay_color: "#0545F5",
overlay_origin: "bottom",
overlay_text_color: "#fff",
overlay_speed: 'fast',
overlay_speed_out : 'slow' });
图像每次都显示在我的开发计算机上,但不在生产服务器上。我用 Firebug 检查了页面,图像似乎正在下降。通常,当我刷新页面或从其他地方返回该页面时,图像会正常显示。有时,其中一两张图像看起来不错,但另一张图像则不然。
任何帮助将不胜感激 - 这让我发疯!
I have seen loads of questions about images not showing but mine seems to be intermittent, Often the image does not appear on the first page view but will be there following a refresh. I am using a JQuery plugin to pop some text up on an image hover.
Here is an HTML snippet (I actually have three images but have added only one here):
<div class="container_24 spacing-bot">
<ul id="topGallery" class="image-overlay">
<li>
<a href="@Url.Action("Index", "Wedding")">
<img src="@Url.Content("~/content/images/photos/image_one.png")" width="290" height="433" alt="Image One."/>
<div class="caption">
<h3>Heading One</h3>
<p>Pop up comment one.</p>
</div>
</a>
</li>
</ul>
The JQuery code at the botton of the page is:
$("#topGallery")
.ImageOverlay({
border_color: "#000",
overlay_color: "#0545F5",
overlay_origin: "bottom",
overlay_text_color: "#fff",
overlay_speed: 'fast',
overlay_speed_out : 'slow' });
The images display every time on my development machine but not on the production server. I checked the page with Firebug and the images seem to be coming down. Often when I refresh the page or go back to it from somewhere else, the images appear as normal. Sometimes one or two of the images will appear fine but the other wont.
Any assistance would be appreciated - this one is driving me loopy!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谢谢你的建议。我删除了所有 jQuery 内容,并且每次都会出现图像。
我继续研究这个问题,发现其他人也有同样的问题。他们通过将 jQuery 代码放入 window.load 函数中解决了这个问题,这似乎也解决了我的问题。
我假设该插件的构造函数中有一些代码用于设置图像的可见性,如果当时未加载图像,则会失败。这可能也解释了为什么它通常会在刷新后或在图像被缓存时返回页面时起作用。
再次感谢。
Thanks for the suggestion. I removed all the jQuery stuff and the images appeared every time.
I carried on researching this and found someone else who had the same problem. They resolved it by putting the jQuery code into the window.load function and this appears to have fixed my problem too.
I assume there is some code in the constructor for this plugin that sets the visibility of the images and this was failing if the images were not loaded at the time. This probably also explains why it would often work after a refresh or when returning to the page as the images were cached.
Thanks again.