gpt4 book ai didi

javascript - 开发人员可以使用哪些 HTML5 图像事件

转载 作者:行者123 更新时间:2023-11-27 23:51:25 25 4
gpt4 key购买 nike

我已经创建了一个 HTML5 网络应用程序。

我使用图像控件。

当分配图像 src 时,我设置一个局部变量 =1图片加载完成后,我将其设置为 0。

如果变量 = 0 并且我的服务器上有另一个可用图像,我将重复该过程。

如果引发 img.onerror,我将局部变量设置为 0

我注意到,如果我的手机失去互联网连接然后恢复,则本地变量“卡在”1 上并且 img.src 永远不会更新。不过,这不会一直发生。

我猜测 img.onload 或 img.onerror 都没有出现。所以我的问题是 img 控件是否引发了任何其他事件,我可以将处理程序放入其中?

代码:

我的 JS 函数被 signalR 通知我的服务器上有一个图像可用。

if (ImageIsLoaded1.Status = 0) {
var d = new Date();
var n = d.getTime();
ImageIsLoaded1.Status = 1;
staticImgArray.src = './NewFrame.ashx?a=' + n
}

staticImgArray.onload = function () { ImageIsLoaded1.Status = 0; };
staticImgArray.onerror = function () { ImageIsLoaded1.Status = 0; };

最佳答案

据官方HTML5 specification ,这里是所有可能的 IDL 定义 global event handlers .作为元素的图像元素应该支持所有这些处理程序。

interface GlobalEventHandlers {
attribute EventHandler onabort;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
attribute EventHandler oncanplaythrough;
attribute EventHandler onchange;
attribute EventHandler onclick;
attribute EventHandler oncuechange;
attribute EventHandler ondblclick;
attribute EventHandler ondurationchange;
attribute EventHandler onemptied;
attribute EventHandler onended;
attribute OnErrorEventHandler onerror;
attribute EventHandler onfocus;
attribute EventHandler oninput;
attribute EventHandler oninvalid;
attribute EventHandler onkeydown;
attribute EventHandler onkeypress;
attribute EventHandler onkeyup;
attribute EventHandler onload;
attribute EventHandler onloadeddata;
attribute EventHandler onloadedmetadata;
attribute EventHandler onloadstart;
attribute EventHandler onmousedown;
attribute EventHandler onmouseenter;
attribute EventHandler onmouseleave;
attribute EventHandler onmousemove;
attribute EventHandler onmouseout;
attribute EventHandler onmouseover;
attribute EventHandler onmouseup;
attribute EventHandler onmousewheel;
attribute EventHandler onpause;
attribute EventHandler onplay;
attribute EventHandler onplaying;
attribute EventHandler onprogress;
attribute EventHandler onratechange;
attribute EventHandler onreset;
attribute EventHandler onresize;
attribute EventHandler onscroll;
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
attribute EventHandler onshow;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
attribute EventHandler onsuspend;
attribute EventHandler ontimeupdate;
attribute EventHandler ontoggle;
attribute EventHandler onvolumechange;
attribute EventHandler onwaiting;
};

关于javascript - 开发人员可以使用哪些 HTML5 图像事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27019934/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com