Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download file, open new tab in browser

After some actions on my site user can donwload file. First, I ask user: "Would you like to download file". This is modal dialog created with fancybox. There are buttons: Yes and No. When user clicks "Yes" I want to open new tab in browser and show standart save file dialog. I have this code:

$(document).on('click', '#agentAcceptSave', function () {
        alert(1);
        window.open = '/ticket?orderId=' + $('#agentOrderId').val();
} 

But, new tab not open and url not calls, but alert is showed. Where is a error?

like image 460
user1260827 Avatar asked Nov 09 '12 03:11

user1260827


People also ask

How do I get downloads to open in a new tab?

You can open a new tab on clicking a link by specifying target="_blank" property in your <a> tag. On this page, you can then display the counter before display the download link.

How do I download a file instead of open in browser?

In most browsers, clicking on the link will open the file directly in the browser. But, if you add the download attribute to the link, it will tell the browser to download the file instead. The download attribute works in all modern browsers, including MS Edge, but not Internet Explorer.

How do I force a file to download instead of open in the browser using HTML?

href = data . This will cause the browser to download the file.


1 Answers

I tried this code and it worked for me:

$(document).on('click', '#download', function() {  
    window.open('http://www.google.com');    
});
like image 68
mohammed momn Avatar answered Oct 27 '22 05:10

mohammed momn