javascript – 在chrome内容脚本中未触发window onload事件

栏目: JavaScript · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/15652291/window-onload-event-not-fired-in-chrome-content-script
我在Chrome扩展程序中使用内容脚本.内容脚本在“document_start”处注入.
window.onload = function() {console.log("window onload event fired.");}

我在内容脚本中运行上面的代码,但是当我加载页面时,不会触发onload事件.

有什么不对的吗?

请查看此代码
if (window.attachEvent) {window.attachEvent('onload', your_function);}
else if (window.addEventListener) {window.addEventListener('load', your_function, false);}
else {document.addEventListener('load', your_function, false);}

翻译自:https://stackoverflow.com/questions/15652291/window-onload-event-not-fired-in-chrome-content-script


以上所述就是小编给大家介绍的《javascript – 在chrome内容脚本中未触发window onload事件》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

Data Structures and Algorithms in Java

Data Structures and Algorithms in Java

Robert Lafore / Sams / 2002-11-06 / USD 64.99

Data Structures and Algorithms in Java, Second Edition is designed to be easy to read and understand although the topic itself is complicated. Algorithms are the procedures that software programs use......一起来看看 《Data Structures and Algorithms in Java》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具