Simulate middle button click

I’m trying to force a link to open in a new tab - is this possible? If I use the target=blank attribute then the default behaviour in most browsers is to open in a new window, so I’m trying to simulate a middle click (this is for an internal page so I’m not too bothered about annoying browsers).

I thought if I capture a left click event and modify the ‘which’ attribute, then re-trigger the event, this might work:


$('#mylink').click(function(e){
		if(e.which==1) e.preventDefault();
		e.which=2;
		$('#mylink').trigger( e );
	});

But nothing happens. Is it even possible? Any suggestions as to how to do it?

No, it is not possible to use JavaScript to tell a web browser to open a new page as a tab.
That is something that the individual web browser settings dictate, according to the user’s desired setting.

For example: see the Firefox options window - tab settings