0

I have this script running at the end of the document loading:

$(function () { $("input").keydown(); }); 

The script is in a chrome-extension that run on each page the user loads and doesn't work (i.e. on twitter website). However, if the same script is executed on the chrome javascript console it work perfectly.

Do you have any clue about how to trigger this event from the script?

5
  • does you call it from content.js ? Commented Oct 31, 2013 at 18:53
  • Well, I have a file called search.js and I put the name of the file on the manifest file to run at document end. The link and the file work fine and if I put some other function inside the $(function(){}); they work perfectly. Also the jQuery script (1.10.2) is called on document end before the search.js script Commented Oct 31, 2013 at 22:08
  • DOM can be manipulated only from content scripts, did you put search.js in to content scripts in manifest ?stackoverflow.com/questions/10066100/… Commented Nov 1, 2013 at 10:36
  • Yes, the script works fine. I also have other scripts inside the function I wrote that add elements to the page and they are correctly inserted. The problem is only when trying to triggering a keydown. Commented Nov 1, 2013 at 15:47
  • 1
    Found this hope this helps. stackoverflow.com/questions/17152932/… Commented Nov 2, 2013 at 5:22

1 Answer 1

0

I fixed the code adding this line and now the keydown even is triggered correctly

var event = new KeyboardEvent('keydown'); document.querySelector('[id="inputid"]').dispatchEvent(event); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.