Few days ago, while developing a web application, I’ve to open a link in a new window by pressing an input button. So I write two lines for this.
$(document).ready(function(){
$(‘#link_id’).click(function(){
window.open(‘url‘, ‘name‘, ‘features‘, ‘replace‘);
return false;
});
});
Demo:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src=" http://code.jquery.com/jquery-1.8.1.min.js "></script>
<script type="text/javascript">
$(document).ready(function(){
$('#btnLink').click(function(){
window.open('http://sharp-coders.blogspot.com', '_blank' , false);
return false;
});
});
</script>
<head>
<body>
<input type="button" id="btnLink" value="Click Here" /> <br />
</body>
</html>