In Google Docs you can open outline pane and see all headers in the document, you can also click on an header and the view will scroll to header.
My question is how simulate mouse click programmatically with JS in Chrome extention, to scroll the view to the desired header?
I tryed following code but nothing hapend:
// usage: eventFire(document.getElementById('mytest1'), 'click');
function eventFire(el, etype) {
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
The headers is an div
elements with class="navigation-item-content navigation-item-level-2"
, When I look in chrome dev tools > event listeners, these elements do not have any event listeners.