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.
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:


Mahendra SinghPosted Apr 21, 2016, 9:32 AM EDT
Nice one
Kishor Bikram OliPosted Apr 20, 2016, 5:23 PM EDT
nice
Vignesh ManiTOP 100Posted Apr 20, 2016, 11:55 AM EDT
Nice
Mohammed IbrahimPosted Apr 20, 2016, 10:48 AM EDT
nice
Debasis SahaTOP 100Posted Apr 20, 2016, 6:23 AM EDT
Good One..
Gowtham RajamanickamTOP 100Posted Apr 20, 2016, 4:35 AM EDT
good article