我在加载脚本和自动播放来自 youtube、vimeo 等的视频时遇到问题。我无法在 webbrowser 控件中从以下脚本加载内容。下面是我的 C# 代码。
string html = "<!doctype html><html><head><title></title></head><body><div id='_cvp_11293'><span></span></div><script type='text/javascript'>(function(){var a;a=new XMLHttpRequest;a.onreadystatechange=function(){rs=a.readyState;if(4==rs&&200==a.status){var c=JSON.parse(a.responseText),b;for(b in c.payload)if(c.payload.hasOwnProperty(b)){var d=c.payload[b];document.getElementById('_cvp_'+b).innerHTML=d.view}}};a.open('GET','http://media.yesheis.com/multi_player?ids=11293&w=300&h=225&autoplay=1&provider=youtube',!0);a.send()})(window);</script></body></html>";
web.IsScriptEnabled = true;
web.NavigateToString(html);
XAML:
<phone:WebBrowser HorizontalAlignment="Left" IsScriptEnabled="True" Margin="36,44,0,0" Grid.Row="1" VerticalAlignment="Top" Name="web" Width="350" Height="500" />