Security Windows 8应用程序-html页面的容器

Security Windows 8应用程序-html页面的容器,security,hyperlink,winjs,temporary-files,Security,Hyperlink,Winjs,Temporary Files,我想创建windows 8 mobile应用程序,作为其他web应用程序的容器。我的意思是,这个应用程序将从我的HTML、CSS和Javascript服务器包下载,保存到数据库,用户可以打开这些下载的应用程序。它适用于Android和iOS,但不适用于Win8 下载并保存到数据库工作。为了打开下载的应用程序I创建临时文件夹,保存所有文件并创建链接 <a href="file://path_to_index.html">Open</a> 但链接没有打开。我猜Windo

我想创建windows 8 mobile应用程序,作为其他web应用程序的容器。我的意思是,这个应用程序将从我的HTML、CSS和Javascript服务器包下载,保存到数据库,用户可以打开这些下载的应用程序。它适用于Android和iOS,但不适用于Win8

下载并保存到数据库工作。为了打开下载的应用程序I创建临时文件夹,保存所有文件并创建链接

<a href="file://path_to_index.html">Open</a>

但链接没有打开。我猜Windows安全策略不允许在移动应用程序中打开本地链接

您对此有什么解决方案或其他方法的想法吗

编辑:

根据jakerella的说法,我尝试将文件写入本地存储并在ms webview中打开它,但它不起作用。函数webview.navigate('ms-appdata:///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);
                        }
                    });
                });
            });
        });
    });
});
$(函数(){
$(“#我的按钮”)。单击(函数(){
var HTML_CONTENT='单击我!';
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)。然后(函数(文件){
Windows.Storage.FileIO.writeTextAsync(文件,HTML\U内容)。然后(函数(){
localFolder.createFileAsync(“index.js”、Windows.Storage.CreationCollisionOption.replaceExisting)。然后(函数(file2){
Windows.Storage.FileIO.writeTextAsync(文件2,JS\U内容)。然后(函数(){
试一试{
var wv=$('#wv')[0];
导航('ms-appdata:///local/index.html');
}捕获(e){
控制台日志(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>

附件1
打开页面
编辑2:


好的,它起作用了!我在这里找到了解决方案:

在我看来,有两种方法

其中一种方法是使用
x-ms-webview
,这就是您所发现的。

另一种方法是通过使用MS强烈不推荐的代码将html直接设置为元素,但我想您可以负责任地使用它。

好吧,这取决于您希望如何“打开”下载的文件。。。这涉及到加载本地资源,但同样的思想也可以应用于链接,即使用
ms-appx
ms-appx-web
协议。当用户点击链接时,你希望发生什么?当我点击链接时,我希望页面被打开。。。哪里怎么用?外部浏览器?在
ms网络视图中
?加载html文件有很多方法。ms-webview可以。我想将文件(html、css、js)写入本地文件夹,然后在ms webview中从此文件夹打开index.html。但是我必须提供给ms webview的index.html的完整地址是什么?如果您将html文件保存到,那么您将使用
ms-appdata:///local/path_to_index.html
使用execUnsafeLocationFunction可以让您有机会询问您是否真的信任代码源。如果这是你自己创造的东西,那就好了。另一方面,如果您是从web上的某个任意位置下载,则可能不是——那么您应该使用Webview或其他容器。