Answered by:
HTML,JavaScript and CSS file referenced in Windows 8 WinRT from Install Location

Question
-
Hi,
I want to refer my html, javascript and css file from install location using
Windows.ApplicationModel.Package.current.installLocation
But i was not able to refer my static file within win 8 app.
Code: This code is refer only js file
var uriInstallLocal = new Windows.Foundation.Uri('ms-appx://src/test.js');
var fileInstallLocal = Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uriInstallLocal );
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uriInstallLocal).done(function(fileInstallLocal ){
var jsPath = fileInstallLocal.path;
var fileref = document.createElement('script');
fileref .setAttribute("type","text/javascript");
fileref .setAttribute("src",jsPath);
document.getElementByTagName("head")[0].appendChild(fileref);
});
Is it possible?
Thanks and Regards,
Shishir
shishir
Thursday, October 17, 2013 6:32 AM
Answers
-
You cannot do this as your application will not pass certification:
See 3.9 - http://msdn.microsoft.com/library/windows/apps/hh694083.aspx
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions @WSDevSol
Getting Started With Windows Azure Mobile Services development? Click here
Getting Started With Windows Phone or Store app development? Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support)- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Friday, October 18, 2013 1:42 PM
- Marked as answer by Jamles HezModerator Monday, October 28, 2013 9:38 AM
Friday, October 18, 2013 1:42 PMModerator
All replies
-
No this will not work. You cannot access the local file path in a Windows Store app.
You can:
Define your page as a new page in your app or read in a text file with the style attributes and then set that into the script instead.
Why are you trying to use this method?
Jeff
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions @WSDevSol
Getting Started With Windows Azure Mobile Services development? Click here
Getting Started With Windows Phone or Store app development? Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support)Thursday, October 17, 2013 2:14 PMModerator -
Aside from Jeff's response, try ms-appx:///src/test.js. The three /// are important for ms-appx URIs. You should be able to access files in your package, because apps do it all the time to load up content that's cached with the package.
Thursday, October 17, 2013 3:49 PM -
Thanks for the reply.
Actually my requirement is like that i want to download some html, js and css file on local folder of app and that file used as a referenced to another html file.
But the issue is windows 8 app is not allowed to access this file from local folder.
http://msdn.microsoft.com/en-us/library/windows/apps/hh781215.aspx
Is there is any other way to do this?
shishir
Friday, October 18, 2013 3:55 AM -
Thanks for the reply.
I try with this only by mistake i have written ms-appx://src/test.js. But this also is not working.
shishir
Friday, October 18, 2013 3:56 AM -
You cannot do this as your application will not pass certification:
See 3.9 - http://msdn.microsoft.com/library/windows/apps/hh694083.aspx
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions @WSDevSol
Getting Started With Windows Azure Mobile Services development? Click here
Getting Started With Windows Phone or Store app development? Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support)- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Friday, October 18, 2013 1:42 PM
- Marked as answer by Jamles HezModerator Monday, October 28, 2013 9:38 AM
Friday, October 18, 2013 1:42 PMModerator