在Windows Phone中是否等同于名为loadHTMLString的IOS方法:baseURL或android loadDatawithBaseUrl(here)。我想在网站上运行脚本,这就是为什么我需要调用这个基本URL。
答案 0 :(得分:-1)
通过查看参考链接,我认为您尝试实现的是Windows Phone上的web browser
控件,以在应用页面上显示远程HTML页面。
第1步:在第x0页的工具箱中加载应用页面上的WebBrowser控件
<Grid x:Name="ContentGrid" Grid.Row="1">
<phone:WebBrowser HorizontalAlignment="Left" Margin="0,0,0,0" Name="webBrowser1" VerticalAlignment="Top" Height="800" Width="470" />
</Grid>
第2步:在page.xaml.cs上编写C#代码(甚至可以使用VB.NET)
webBrowser1.Source = new Uri("http://www.foo.com", UriKind.Absolute);
此处步骤1保持不变,只是为了在本地加载HTML代码:
第2步:第xxl.cs页上的C#代码
String htmlContent = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1250\">
<meta name=\"spanish press\" content=\"spain, spanish newspaper, news,economy,politics,sports\">
<title></title>
</head>
<body id=\"body\">
<!-- The following code will render a clickable image ad in the page -->
<script src=\"http://www.myscript.com/a\"></script>
</body>
</html>";
webBrowser1.NavigateToString(htmlContent); //This renders the HTML string defined above in the webview.
编辑另外,如果您想允许脚本在Webview中执行,请将webbrowser控件的IsScriptEnabled
属性设置为true
。
webBrowser1.IsScriptEnabled = true;