Reputation: 1549
I have tried the following to achieve this:
But neither works when calling window.open
from inside the callback. Here's my code
$.post('api', {
}, function() {
var win = window.open('target-file', '_blank');
win.focus();
});
Upvotes: 2
Views: 7720
Reputation: 1076
ou can add this simple jQuery snipplet to your source to open every external link in a new tab of the web browser
$(document).ready(function(){
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
});
Upvotes: 0
Reputation: 107
Try this:
$.post('api', {
}, function() {
window.open('target-file', '_blank');
});
Upvotes: 2
Reputation: 3610
use MySurfaceWindow = window.open("url","windowname","settings");
see below example:
MySurfaceWindow = window.open('/DesktopModules/DMS/DMS.PatientEChart/Surface Pages/Surface6.aspx?SurfaceTooth=' + $("#lbl" + $(this).val()).text() + '&ProcedureID=0' + '&ColorD=I' + '', '', 'height=240,width=200,top=' + top + ',left=' + left + 'status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no');
Upvotes: 0