关于网友提出的“WP7,让WebBrowser从独立存储中加载css/js文件以及图片文件”问题疑问,本网通过在网上对“WP7,让WebBrowser从独立存储中加载css/js文件以及图片文件”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题:WP7,让WebBrowser从独立存储中加载css/js文件以及图片文件
接着在WP7的页面初始化方法中添加以下代码:
CopyContentToIsolatedStorage("html/themes/images/ajax-loader.png");
CopyContentToIsolatedStorage("html/themes/images/icons-18-black.png");
CopyContentToIsolatedStorage("html/themes/images/icons-18-white.png");
CopyContentToIsolatedStorage("html/themes/images/icons-36-black.png");
CopyContentToIsolatedStorage("html/themes/images/icons-36-white.png");
CopyContentToIsolatedStorage("html/jquery-1.7.1.min.js");
CopyContentToIsolatedStorage("html/jquery.mobile-1.0.1.min.js");
CopyContentToIsolatedStorage("html/style.css");
CopyContentToIsolatedStorage("html/jquery.mobile.structure-1.0.1.min.css");
然后,我们只需要拼接好HTML字符串然后发送到WebBrowser控件就行了,但是,请小心,为了强制WebBrowser控件加载html代码以及所有对应的文件,你必须将html代码也以文件的方式存储到独立存储中,而且还必须存储到与css/js文件相同的根目录中。
string htmlFromWS = ...;
// Concat our html
string html = BuildHTML(htmlFromWS);
var bytes = Encoding.UTF8.GetBytes(html);
// Get the iso store
IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
// Write the html in the html/index.html
using (IsolatedStorageFileStream output = iso.CreateFile("html/index.html"))
{
output.Write(bytes, 0, bytes.Length);
}
// navigate to the html/index.html
wb.Navigate(new Uri("html/index.html", UriKind.Relative));
终于,现在WebBrowser控件将从独立存储中加载css/js文件以及你的html代码!
好了,你也可以从这里下载到整个演示的源码:Download Source_code.zip - 102.33 KB
解决方案1:
真的耶
解决方案2:
好像还是不能下载噢
解决方案3:
代码怎么下载不下来啊
以上介绍了“WP7,让WebBrowser从独立存储中加载css/js文件以及图片文件”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1151981_2.html