Universal Windows Platform provides the common application platform and lets developers build apps using JavaScript/HTML, C#/XAML and C++, etc. As we all know the WinJS library helps us build Windows 10 universal Apps in HTML5 and JavaScript. The WinJS.xhr in WinJS helps wrap cross-domain calls and provides an easy mechanism to work with external web contents using HTTP operations like POST/ GET etc.
Let’s see the steps.
Create new windows 10 universal appp using WinJS. For creating a new Windows 10 universal project, refer to the following:
Create new windows 10 universal appp using WinJS. For creating a new Windows 10 universal project, refer to the following:
Now go to your default.html page and write the following code inside the body tag.
- <table style="width: 100%;border:double">
- <tr>
- <td> Enter Url Here
- <td>
- </tr>
- <tr>
- <td> <input id="txturl" type="text" style="width:800px" /> </td>
- <td> <input id="btngetfile" type="button" value="Download" /> </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td align="center">
- <div id="dvcontainer"> </div>
- </td>
- </tr>
- </table>
Now go to your default.js file present under js folder in the solution files and write the following code inside the function tag to perform the download button click event.
- var page = WinJS.UI.Pages.define("default.html",
- {
- ready:function(element,options)
- {
- document.getElementById("btngetfile").addEventListener("click", downloadFile, false);
- },
- });
- function downloadFile() {
- var url = document.getElementById('txturl').value;
- WinJS.xhr({ url: url, responseType: "blob" })
- .done(function (r) {
- var fileURL = URL.createObjectURL(r.response);
- var image = dvcontainer.appendChild(document.createElement("img"));
- image.src = fileURL;
- });
- }
Now run the app and enter your image URL into the textbox and click download button it will show the output like the following screen.

For more information on Windows 10 UWP, refer to my e-book:
Read more articles on Universal Windows Platform:

Mahendra SinghPosted Apr 21, 2016, 1:32 PM
Nice one
Kishor Bikram OliPosted Apr 20, 2016, 9:23 PM
nice
Vignesh ManiPosted Apr 20, 2016, 3:55 PM
Nice
Mohammed IbrahimPosted Apr 20, 2016, 2:48 PM
nice
Debasis SahaPosted Apr 20, 2016, 10:23 AM
Good One..
Gowtham RajamanickamPosted Apr 20, 2016, 8:35 AM
good article