简体   繁体   English

javascript事件:当图像开始加载时挂钩(已经有自然宽度和自然高度道具但尚未加载自身)

[英]javascript event: hook when image starts loading ( already has naturalWidth & naturalHeight props but haven't loaded itself yet)

有没有这样的事件或技巧来执行代码,你可以在使用javascript创建之后获得<img>自然大小但是你不必等待它完全加载(图像可能是5mb所以你必须等待10它会被“加载”+秒,但是当它刚开始加载时你可以立即获得它的自然尺寸(几毫秒) - 我想知道它获得自然尺寸道具并钩住它的时间)

There is an event onloadedmetadata that supposedly applies to img elements. 有一个事件onloadedmetadata应该适用于img元素。

Source 资源

Copying from the source above: 从上面的来源复制:

onloadedmetadata: Script to be run when meta data (like dimensions and duration) are loaded onloadedmetadata:加载元数据(如维度和持续时间)时要运行的脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么无法在javascript / JQuery中获取图像的naturalHeight / naturalWidth? - Why can't I get the naturalHeight/naturalWidth of an image in javascript/JQuery? naturalHeight 和 naturalWidth Javascript 的问题 - problem with naturalHeight and naturalWidth Javascript javascript事件:获取文本完全加载但脚本尚未运行的时间 - javascript event: get when document is textually fully loaded but scripts haven't ran yet naturalWidth 和 naturalHeight 使用 onload 事件返回 0 - naturalWidth and naturalHeight returns 0 using onload event Random 尝试获取图像的 naturalHeight 和 naturalWidth 失败 - Random fails trying to get the naturalHeight and naturalWidth of an image 从 onLoad() 返回的 React 合成事件<image>里面的元素<svg>没有 naturalWidth 或 naturalHeight 属性 - React synthetic event returned from onLoad() of <image> element inside <svg> does not have naturalWidth or naturalHeight properties naturalHeight与naturalWidth的比较 - naturalHeight comparison with naturalWidth naturalHeight 和 naturalWidth 属性是新增的还是已弃用? - naturalHeight and naturalWidth property new or deprecated? jQuery-如何处理尚未加载的可点击元素 - jQuery - how to handle clickable elements, that haven't loaded yet 如何检查已加载的图像是否已加载JavaScript? - How do I check if an already loaded image has loaded in JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM