Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在WebBrowser控件中加载本地文件_Javascript_Html_Windows Phone 7_Browser_Local - Fatal编程技术网

Javascript 在WebBrowser控件中加载本地文件

Javascript 在WebBrowser控件中加载本地文件,javascript,html,windows-phone-7,browser,local,Javascript,Html,Windows Phone 7,Browser,Local,我试图在WindowsPhone7.1上的WebBrowser中加载本地文件,但我总是收到异常或空白页 我试过了 Stream stream = Application.GetResourceStream( new Uri("./Html/par/index.html", UriKind.Relative)).Stream; using (StreamReader reader = new StreamReader(s

我试图在WindowsPhone7.1上的WebBrowser中加载本地文件,但我总是收到异常或空白页

我试过了

Stream stream = Application.GetResourceStream(
                   new Uri("./Html/par/index.html", 
                   UriKind.Relative)).Stream;
using (StreamReader reader = new StreamReader(stream))
{
    // Navigate to HTML document string
    this.webBrowser.NavigateToString(reader.ReadToEnd());
}
这是一个空白页

我将index.html和所有需要的文件(css/js)设置为内容,并将IsScriptEnable设置为“true”


你知道如何解决这个问题吗?

我认为路径不正确

您的项目中是否有
/Html/par
目录?第二,index.html是否设置为content

试一试

这可能会有帮助

这可能有助于理解资源和内容之间的差异

此链接详细说明如何加载文件和其他链接文件

StreamReader=新的StreamReader(TitleContainer.OpenStream(“test.html”);webBrowser1.NavigateToString(reader.ReadToEnd());我也用过这个。问题不是路径,而是加载指定的html,而不是本地脚本/样式文件/图像。你知道如何传输这些文件吗?试试这个链接谢谢!!它的工作就像一个魅力,但很遗憾,我们必须这样做加载本地文件…我希望有第二种方法…但这是最好的答案!!干杯我同意。。。最简单的方法是使用所有css和javascript创建更简单的html文件,而不是链接它。很高兴它成功了是的,我在我可以使用它的地方也使用了这个解决方案…对于图像和长js im使用“复制”解决方案!!谢谢你!
var rs = Application.GetResourceStream(new Uri("myFile.html", UriKind.Relative));
using(StreamReader sr = new StreamReader(rs.Stream))
{
    this.webBrowser.NavigateToString(sr.ReadToEnd()); 
}