window document addEventListener

519 views
Skip to first unread message

Jack$ Mon

unread,
Mar 23, 2012, 9:03:31 AM3/23/12
to Chromium-extensions
Hi,

I have one question regarding "document.addEventListener".

I would like to listen one event on page loaded (for all open winows
and all tabs) so what could be the best way for that ?

I am trying like that but its not working fine

chrome.webNavigation.onDOMContentLoaded.addListener(
function(details) {
document.addEventListener('AddonNotifierForLoggedIn',
function () {
alert("Event detected: AddonNotifierForLoggedIn");
console.log("Event detected:
AddonNotifierForLoggedIn");
});
});


Can some one plese help to short ot this issue ?

Regards,
Jack

PhistucK

unread,
Mar 26, 2012, 2:54:12 AM3/26/12
to Jack$ Mon, Chromium-extensions
I assume this code resides in the background page/script.
So, in this case, "document" refers to the document of the background page/script, not to the document of the tab from which the onDOMContentLoaded event is originated.
You will have to use chrome.tabs.executeScript in order to run code within the context of the tab.
(Or, unless the posted code is a very reduced and simplified version of your code, maybe just use a content script with a "run_at": "document_end" property.)

PhistucK




--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


Reply all
Reply to author
Forward
0 new messages