j-ulrich / jquery-simulate-ext

jQuery simulate extended
https://j-ulrich.github.io/jquery-simulate-ext/
Other
146 stars 48 forks source link

i can simulate "ctrl" pressed ? #35

Closed iwacham closed 8 years ago

iwacham commented 8 years ago

i can simulate this ? on mouseover event simulate ctrl pressed to open a link on new tab

the reason is the link is on iframe.

j-ulrich commented 8 years ago

You can simulate the Ctrl key being pressed like this (i assume you rather want a click event instead of a mouseover):

$('#myEle').simulate('click', { ctrlKey: true })

However, this will most likely not open a link in a new tab unless the website explicitly implements that via window.open() or similar. The reason for this is that simulated events do not trigger browser behavior but only website behavior. That means you can trigger behavior which has been defined via JavaScript (for example with $('#myEle').on('click', /*...*/)) or behavior of the DOM but not behavior the browser adds on top of that (like opening in new tab/window).