can not find out if the div element is already set in body in chrome extension
Posted
by
alpham8
on Stack Overflow
See other posts from Stack Overflow
or by alpham8
Published on 2013-10-25T09:51:35Z
Indexed on
2013/10/25
9:53 UTC
Read the original article
Hit count: 152
in my chrome extension I got an div, which I will add to the body of the current tab. I am listening to chrome.tabs.onUpdated. If this event is called, I execute a script inside content_scripts. In this function there I´ll wait till the document is ready with jQuery $(document).ready(...). I try to access
$("#div").length
and sometimes it returns 1 and sometimes 0. It should added to the body, if it´s not already there.
For some strange reasons, the onUpdated event is called twice on each page reload. Actually I found no way to check safely if the div was already added.
© Stack Overflow or respective owner