Skip to content Skip to sidebar Skip to footer

How To Open A Downloaded File?

I have a link to the file. How do I know that the user clicked on the link and download the file? I need to get downloadId? Google Chrome API has a method chrome.downloads.open (in

Solution 1:

You can try this example code below tested in Google Chrome Version 38.0.2125.111 m (64-bit)

chrome.downloads.onChanged.addListener(function (detail){
console.log("Detail",detail); //Save log for debugging

    //if file download finished
   if(detail.state.current == "complete"){

       var downloadId = detail.id; //Download ID

       console.log("Download ID",downloadId); //Save log for debugging
       /*
       Do Something
        */

   }
});

Post a Comment for "How To Open A Downloaded File?"