DOM Event Simulate
Simulator of manual dom events for habrahabr comment
by azproduction
HTML
<p><a href="http://ya.ru/" id="link">Link to ya.ru</a></p>
<button onclick="simulateClick(true, true, false);">Simulate Ctrl+Shift+Click</button>
<button onclick="simulateClick(true, false, false);">Simulate Ctrl+Click</button>
<button onclick="simulateClick(false, false, false);">Simulate Click</button>
<button onclick="simulateClick(false, false, true);">Simulate Middle mouse button click</button>
JavaScript
var simulateClick = function (ctrl, shift, isMiddle) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, ctrl, false, shift, false, isMiddle ? 1 : 0, null );
document.getElementById('link').dispatchEvent(evt);
}