我面临以下奇怪的问题:
功能:
当我打开我的网站页面时,该页面包含许多图像并使用 Javascript/jQuery 作为客户端功能。单击每个图像时,所有其他图像都会更改其不透明度,并且所选图像会显示<div>
包含一些信息和图像的视频。
- 我使用了 jQuery Reveal,它仅在页面上触发滚动事件后才加载所有图像。在此之前,它会显示“正在加载”图像。
- 我已经添加了一个Javascript
window.onload
调整大小的事件<div>
单击图像时的元素。还有一些 Javascript 可以识别浏览器并相应地设置视频标签源。
- 所有图像都呈现在数据列表内,并与数据库绑定。
- 由于 Reveal 仅在滚动事件后加载图像,因此我在页面加载时添加了一段代码,以人为地按像素滚动页面。
Problem:
我在 Chrome 或 Safari 上的 iPad(iOS 8.4) 中打开同一页面。我所有的Javascript都在window.onload
不着火。
ASPX 页面:
<script type="text/javascript" src="/js/jquery.unveil.js"></script>
<asp:DataList ID="dlPersonList" runat="server" OnItemDataBound="dlPersonList_OnItemDataBound"
RepeatDirection="Horizontal" RepeatLayout="Flow">
<ItemTemplate>
<div class="itemImage">
<asp:HyperLink ID="hypPersonPicture" runat="server">
<asp:Image ID="imgPersonPicture" runat="server" CssClass="lazy" />
</asp:HyperLink>
</div>
<asp:Panel class="person-detail" ID="pnlpersonDetail" runat="server">
<div class="person-content detailView">
<%--Some text and other controls--%>
<asp:Panel ID="pnlVideo" runat="server">
<div class="video-content">
<video id="personVideo" controls="controls" preload="none">
<%--Video source elements--%>
</video>
</div>
</asp:Panel>
</div>
</asp:Panel>
</ItemTemplate>
</asp:DataList>
CS code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Bind data list
dlPersonList.DataSource = SelectPersons();
dlPersonList.DataBind();
// Register the script for slide up effect
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptPerson", @"$(document).ready(function () {
jWDScrollWindow();});",
true);
}
}
protected void dlPersonList_OnItemDataBound(Object sender, DataListItemEventArgs e)
{
/*Lazy loading functionality*/
//Set the image source as loader image
imgPersonPicture.Attributes.Add("src", "/img/loading.gif");
//set image resource as actual image
imgPersonPicture.Attributes.Add("data-src", imageObject.ImagePath.TrimStart('~'));
}
JS code:
window.onload = function () {
//Apply lazy loading functionality to images
$(".lazy").unveil();
//Javascript to set the width and height of the details div
.
.
//Javascript to blur all the other images when one image is clicked
}
function jWDScrollWindow() {
//scroll by 1px to load the images
$(window).scrollTop($(window).scrollTop() + 1);
}
我已经尝试过的事情:
- 我认为 jQuery 发布可能会使页面变慢或者其他什么。所以,我删除了通话,但问题是
unveil();
被称为内window.onload
。因此,如果window.onload
没有被解雇,揭开面纱没有任何意义。
- 我添加了一个
alert()
on window.onload()
,但在这种情况下,一切都很完美。
所有功能在除 iOS 8.4 的 ipad 之外的所有设备上都能完美运行(即使在早期操作系统中也能正常运行)
非常感谢帮助/建议。
EDIT:
我找到了一个js控制台 http://jsconsole.com通过它我们可以在桌面上看到iPad中的控制台日志。Here https://blog.idrsolutions.com/2015/02/remote-debugging-ios-safari-on-os-x-windows-and-linux/就是我们如何使用它。
我检查了日志,发现当我收到错误时JQMIGRATE: jQuery.browser is deprecated
, My window.onload
事件不会触发。然而,如果我得到日志JQMIGRATE: Logging is active
,一切正常。
我的jqmigrate
参考在母版页中为,
<script type="text/javascript" async src='/js/jquery-migrate-1.1.1.js'></script>