有没有办法从DOMContentLoaded
?
window.addEventListener("load", function() { myExtension.init(); }, false);
var myExtension = {
init: function() {
var appcontent = document.getElementById("appcontent"); // browser
if(appcontent)
appcontent.addEventListener("DOMContentLoaded", myExtension.onPageLoad, true);
},
onPageLoad: function(aEvent) {
//how to access to the DOM from aEvent??
},
}
来自https://developer.mozilla.org/en/Code_snippets/On_page_load
答案 0 :(得分:1)
您链接到的页面上onPageLoad
的第一行显示了如何:
var doc = aEvent.originalTarget; // doc is document that triggered "onload" event
这会为您提供网站的document
元素。