我想創建Windows 8移動應用程序作爲其他Web應用程序的容器。我的意思是這個應用程序會從我的服務器包下載HTML,CSS & Javascript,將它保存到數據庫,用戶可以打開這些下載的應用程序。它適用於Android和iOS,但不適用於Win8。Windows 8應用程序 - HTML頁面的容器
下載並保存到數據庫工程。爲了打開下載的應用程序創建的臨時文件夾,保存有所有文件並創建鏈接
<a href="file://path_to_index.html">Open</a>
但鏈接不開放。我猜Windows安全策略不允許在移動應用中打開本地鏈接。
你有任何解決方案這個或任何想法到替代方法?
編輯:
我試着寫文件到本地存儲,並根據jakerella在MS-web視圖中打開它,但它不工作。功能webview.navigate( 'MS-應用程序數據:///local/index.html')拋出異常:錯誤的參數
的Javascript:
$(function() {
$('#my_button').click(function() {
var HTML_CONTENT = '<!DOCTYPE html> <html> <head> <title></title> </head> <body> <button id="btn">Click me!</button> <div id="content"></div> <script type="text/javascript" src="index.js"></script> </body> </html>';
var JS_CONTENT = 'document.getElementById("btn").onclick=function(){var a=document.getElementById("content");a.innerHTML="Clicked!"};';
var localFolder = Windows.Storage.ApplicationData.current.localFolder;
localFolder.createFileAsync("index.html", Windows.Storage.CreationCollisionOption.replaceExisting).then(function (file) {
Windows.Storage.FileIO.writeTextAsync(file, HTML_CONTENT).then(function() {
localFolder.createFileAsync("index.js", Windows.Storage.CreationCollisionOption.replaceExisting).then(function (file2) {
Windows.Storage.FileIO.writeTextAsync(file2, JS_CONTENT).then(function() {
try {
var wv = $('#wv')[0];
wv.navigate('ms-appdata:///local/index.html');
} catch (e) {
console.log(e.message);
}
});
});
});
});
});
});
和HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App1</title>
<!-- WinJS references -->
<link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.2.0/js/base.js"></script>
<script src="//Microsoft.WinJS.2.0/js/ui.js"></script>
<script src="js/jquery-2.1.0.min.js"></script>
<script src="js/script.js"></script>
<!-- App1 references -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
</head>
<body>
<button id="my_button">Open page</button>
<x-ms-webview id="wv">
</x-ms-webview>
</body>
</html>
EDIT2:
行,行!我在這裏找到了解決方案:http://blogs.windows.com/windows/b/appbuilder/archive/2013/10/01/blending-apps-and-sites-with-the-html-x-ms-webview.aspx
那麼,這取決於你想「打開」下載的文件...這[文檔頁](http://msdn.microsoft.com/en-us/library/windows/apps/hh781229.aspx)談論加載本地資源,但同樣的想法可以應用於鏈接,這是你使用'ms-appx'或'ms-appx-web'協議。當用戶點擊鏈接時你想要發生什麼? – jakerella
當我點擊鏈接我想要打開頁面 – luski
呃呃......在哪裏?怎麼樣?外部瀏覽器?在'ms-webview'中?有很多方法可以加載一個html文件。 – jakerella