I want to present https://translate.yandex.com/m/translate page to user with preselected source and destination language. I can access to interesting element like this
var srcLangContent = document.getElementById("srcLanguagesContent")
var liToSelect = srcLangContent.children[10]
What to do next I don't know. I called click()
, but it's not working. Can you give some advice?
PS I can't use jQuery
Here is solution.
var mouse_down_evt = document.createEvent("MouseEvents");
mouse_down_evt.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
var mouse_up_evt = document.createEvent("MouseEvents");
mouse_up_evt.initMouseEvent("mouseup", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
liToSelect.dispatchEvent(mouse_down_evt)
liToSelect.dispatchEvent(mouse_up_evt)
Thank you @PhilCooper for advice.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.