在Opera's用户js中,当页面完成加载并下载了所有资源(如img,script,css等)时,使用什么事件名
What event name use in Opera's userJS to trigger a function when page finished loading and has downloaded all its assets like img,script,css etc.?
这是我的代码:
document.addEventListener('load', function () {
alert(document.getElementsByTagName("DIV").length);
}, false);
//'load' event above doesn't show any response, alert isn't showing
alert(document.getElementsByTagName("DIV").length);
// this alert returns 0 it looks like it is called before the page DOM has loaded
window.onload = function() {
alert(document.getElementsByTagName("DIV").length);
};
//returns 0, what the... it seems DOM hasn't loaded also
// but only on some sites, here on stackoverflow and youtube it works,
//but on google.com and many other websites (pcworld.com) shows 0
在最新的稳定版和alpha版opera中也是如此。
我建议你直接做
window.addEventListener('load', function(){}, false)
就像在正常脚本中一样。您可以使用opera.addEventListener('BeforeEvent.load', ...)
,但如果页面的脚本在某些Opera版本中不侦听加载事件,则可能不会触发。
其他一些背景阅读:窗口。Onload vs document.onload
addEventListener("input", callback)在opera中不工作?
相关文章:
- 如何更改<svg>标记为<img>用js标记
- 有没有一种方法可以防止img get请求使用css或js发生
- Javascript:使用绝对路径设置img src
- Setting default onclick behavior for <img> tag in gene
- 如何在页面加载中使用Jquery/Javascript确定img源
- html文件中的script标记根本不起作用
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 使用AngularJs时,如何在img标记具有src-attr时设置数据src
- 插入“;img src"在javascript中
- 检索MongoDB binData并显示为<img>src
- 用javascript将script元素附加到头部;铬不能工作
- script标记如何解析node_modules的路径
- addEventListener的Javascript代码不工作!?(单击时打开放大的img)
- 手柄'img'单击事件并插入'alt'使用jQuery将属性转换为文本框
- 限制对HTML/CSS/IMG或根索引文件夹的访问
- 使用javascript或angularjs特定过滤器搜索字符串中第一个img标记的json值
- 在<script src=“"></脚本>标签
- Google Script HtmlService,通过多个选项卡复制URL变量
- 在Opera's用户js中,当页面完成加载并下载了所有资源(如img,script,css等)时,使用什么事件名
- 从url中提取img-Script在jsfiddle中有效,但在我的网站上无效,任何人都能发现原因