Windows Phone7开发之 Web控件
webphp
13年前
<p style="text-indent:0px;margin:5px auto;"><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">是</span><span style="line-height:21px;font-family:Calibri,sans-serif;font-size:10.5pt;" lang="EN-US">phone7</span><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">中的浏览器控件,它是基于</span><span style="line-height:21px;font-family:Calibri,sans-serif;font-size:10.5pt;" lang="EN-US">Internet Explorer7</span><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">的,可以直接嵌入到应用程序中。这个控件相对于</span><span style="line-height:21px;font-family:Calibri,sans-serif;font-size:10.5pt;" lang="EN-US">Windows mobile</span><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">也有了许多的不同。另外这个控件与</span><span style="line-height:21px;font-family:Calibri,sans-serif;font-size:10.5pt;" lang="EN-US">MediaElement </span><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">一样,只是一个基本显示窗口,所有的控制都需要自已来完成。如</span><span style="line-height:21px;font-family:Calibri,sans-serif;font-size:10.5pt;" lang="EN-US">Forward</span><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">、</span><span style="line-height:21px;font-family:Calibri,sans-serif;font-size:10.5pt;" lang="EN-US">Backward</span><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">、</span><span style="line-height:21px;font-family:Calibri,sans-serif;font-size:10.5pt;" lang="EN-US">Refresh</span><span style="line-height:21px;font-family:宋体;font-size:10.5pt;">等。</span></p> <p style="text-indent:0px;margin:5px auto;" align="left"><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;"><</span><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">phone</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">:</span><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">WebBrowser</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> Grid.Row</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="1"</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> HorizontalAlignment</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="Left"</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> Name</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="webBrowser1"</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> VerticalAlignment</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="Top"</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> Height</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="649"</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> Width</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="480"</span><span style="line-height:19px;font-family:NSimSun;font-size:9.5pt;"> <span style="line-height:19px;color:red;"> Source</span><span style="line-height:19px;color:blue;">="http://www.baidu.com" </span><span style="line-height:19px;color:red;">IsScriptEnabled</span><span style="line-height:19px;color:blue;">="False"/></span></span></p> <p style="text-indent:19pt;margin:5px auto;"><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">Source:</span><span style="line-height:19px;font-family:宋体;color:#a31515;font-size:9.5pt;">要加载的</span><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">HTML</span><span style="line-height:19px;font-family:宋体;color:#a31515;font-size:9.5pt;">页。</span></p> <p style="text-indent:19pt;margin:5px auto;"><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">IsScriptEnabled:</span><span style="line-height:19px;font-family:宋体;color:#a31515;font-size:9.5pt;">是否运行页面脚本。默认为不可用。</span></p> <p style="text-indent:0px;margin:5px auto;"><span style="line-height:19px;font-family:宋体;">该控件可以完成以下功能:</span></p> <p style="text-indent:10.5pt;margin:5px auto;"><span style="line-height:19px;font-family:宋体;">动态加载</span>HTML<span style="line-height:19px;font-family:宋体;">内容:</span></p> <p style="text-indent:0px;margin:0cm 0cm 0pt 60.75pt;"><span style="line-height:19px;font-family:Consolas;color:black;">webBrowser1.NavigateToString(</span><span style="line-height:19px;font-family:Consolas;color:#a31515;">"<html><head><meta name='viewport' content='width=480, user-scalable=yes' /></head><body>HTML Text</body></html>"</span><span style="line-height:19px;font-family:Consolas;color:black;">);</span></p> <p style="text-indent:10.5pt;margin:5px auto;"><span style="line-height:19px;font-family:宋体;">加载静态</span>HTML<span style="line-height:19px;font-family:宋体;">页面或</span>Isolate Storage<span style="line-height:19px;font-family:宋体;">上的</span>HTML<span style="line-height:19px;font-family:宋体;">页面</span>:</p> <p style="text-indent:0px;margin:5px auto;word-break:break-all;"><span style="line-height:19px;"> </span><span style="line-height:19px;font-family:Consolas;color:black;">webBrowser1.Navigate(</span><span style="line-height:19px;font-family:Consolas;color:blue;">new</span><span style="line-height:19px;font-family:Consolas;color:black;"> Uri(</span><span style="line-height:19px;font-family:Consolas;color:#a31515;">"readme.htm"</span><span style="line-height:19px;font-family:Consolas;color:black;">, UriKind.Relative));</span></p> <p style="text-indent:10.5pt;margin:5px auto;"><span style="line-height:19px;font-family:宋体;">加载网络上的</span>Web<span style="line-height:19px;font-family:宋体;">页面:</span></p> <p style="text-align:left;text-indent:57.75pt;margin:5px auto;word-break:break-all;" align="left"><span style="line-height:19px;font-family:Consolas;color:black;">webBrowser1.Source = </span><span style="line-height:19px;font-family:Consolas;color:blue;">new</span><span style="line-height:19px;font-family:Consolas;color:black;"> Uri(</span><span style="line-height:19px;font-family:Consolas;color:#a31515;">"http://www.baidu.com"</span><span style="line-height:19px;font-family:Consolas;color:black;">, UriKind.Absolute);</span></p> <p style="text-indent:0px;margin:5px auto;"><span style="line-height:19px;font-family:宋体;">另外,这个控件还支持</span>.xhtml<span style="line-height:19px;font-family:宋体;">的浏览。</span></p> <p style="text-indent:0px;margin:5px auto;" align="left"><span style="line-height:19px;font-family:宋体;">如:</span><span style="line-height:19px;font-family:NSimSun;">webBrowser1.Navigate(<span style="line-height:19px;color:blue;">new</span> <span style="line-height:19px;color:#2b91af;">Uri</span>(<span style="line-height:19px;color:#a31515;">"http://www.flashkit.com/index.xhtml"</span>, <span style="line-height:19px;color:#2b91af;">UriKind</span>.Absolute));</span> </p> <p style="text-indent:0px;margin:5px auto;"><span style="line-height:19px;font-family:宋体;">但是该控件也有一些无法完成的功能:</span></p> <p style="text-indent:21pt;margin:5px auto;"><span style="line-height:19px;font-family:宋体;">无法浏览</span>https<span style="line-height:19px;font-family:宋体;">页面;</span></p> <p style="text-indent:0px;margin:5px auto;"><span style="line-height:19px;"> </span><span style="line-height:19px;font-family:宋体;">无法显示加密图标;</span></p> <p style="text-indent:0px;margin:5px auto;"><span style="line-height:19px;"> </span><span style="line-height:19px;font-family:宋体;">不支持</span>Plug-ins<span style="line-height:19px;font-family:宋体;">。</span></p> <p style="text-indent:0px;margin:5px auto;" align="left"><span style="line-height:19px;font-family:宋体;">如:</span><span style="line-height:19px;font-family:NSimSun;">webBrowser1.Navigate(<span style="line-height:19px;color:blue;">new</span> <span style="line-height:19px;color:#2b91af;">Uri</span>(<span style="line-height:19px;color:#a31515;">"https://ibsbjstar.ccb.com.cn/V5/index.html"</span>, <span style="line-height:19px;color:#2b91af;">UriKind</span>.Absolute));</span></p>