I am creating a Google Chrome extension that adds a keyboard shortcut for the link "Display images below" in Gmail using jQuery.
I have tried the following to simulate the click unsuccessfully:
$("#canvas_frame").contents().find("span:contains(Display images below)").mousedown().mouseup().click();
$("#canvas_frame").contents().find("span:con开发者_JAVA百科tains(Display images below)").click();
$("#canvas_frame").contents().find("span:contains(Display images below)").mousedown();
$("#canvas_frame").contents().find("span:contains(Display images below)").mouseup();
$("#canvas_frame").contents().find("span:contains(Display images below)").trigger('click');
Could someone point me in the right direction?
var event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
$("#canvas_frame span:contains(Display images below)")[0].dispatchEvent(event);
Note: don't forget that GMail is multilingual, you may need a better method of selecting the element!
精彩评论