I would like to have a button that redirects to a given URL and opens in a new tab. How can this be done?
You can't. This behaviour is only available for plugins and can only be configured by the user.
Use this:
<input type="button" value="button name" onclick="window.open('http://www.website.com/page')" />
Worked for me and it will open an actual new 'popup' window rather than a new full browser or tab. You can also add variables to it to stop it from showing specific browser traits as follows:
onclick="window.open(this.href,'popUpWindow','height=400,width=600,left=10,top=10,,scrollbars=yes,menubar=no'); return false;"
Adding target="_blank" should do it:
<a id="myLink" href="www.google.com" target="_blank">google</a>
<BUTTON NAME='my_button' VALUE=sequence_no TYPE='SUBMIT' style="background-color:transparent ; border:none; color:blue;" onclick="this.form.target='_blank';return true;"><u>open new page</u></BUTTON>
This button will look like a URL and can be opened in a new tab.
try this
<a id="link" href="www.gmail.com" target="_blank" >gmail</a>
USE this code
function openBackWindow(url,popName){
var popupWindow = window.open(url,popName,'scrollbars=1,height=650,width=1050');
if($.browser.msie){
popupWindow.blur();
window.focus();
}else{
blurPopunder();
}
};
function blurPopunder() {
var winBlankPopup = window.open("about:blank");
if (winBlankPopup) {
winBlankPopup.focus();
winBlankPopup.close()
}
};
IT works fine in Mozilla,IE and chrome on and less than 22 version; but doesn't work in Opera and Safari.