开发者

How to click programmatically on "Display images below" in Gmail using jQuery?

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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜