I’m a bit stumped on why this isn’t working. I’m trying to get the title of a document that’s loading in the browser. Unfortunately my code is producing a weird error.
let lg = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
window.addEventListener("load", function p7Foxload() {
window.removeEventListener("load", p7Foxload, false);
gBrowser.addEventListener("DOMContentLoaded", function(event){
if(event.originalTarget instanceof HTMLDocument) {
lg.logStringMessage(event.originalTarget.getAttribute('title'));
}
}, false);
}, false);
It gives me the following error:
event.originalTarget.getAttribute is not a function
I don’t understand why it’s saying the getAttribute method is not a function.
That’s because a
HTMLDocumentjust doesn’t have it. Useevent.originalTarget.titleinstead.