Cannot change VIDEO tag size via InvokeScript of WPF WebBrowser control

柔情痞子 提交于 2020-01-16 09:07:09

问题


I do very simple thing: I need to change VIDEO tag size via InvokeScript of WPF WebBrowser control.

So it shows "Hello" but size doesn't changes at all.

Note: If i open this page directly it changes size fine for any browser.

private void btSize_Click(object sender, RoutedEventArgs e)
{
   wb.InvokeScript("SetVideoSize");
}

function SetVideoSize() {

            try {
                document.getElementById("player1").style.height = '400px';
                document.getElementById("player1").style.width = '400px';
                alert('Hello2');
  } catch (e) {
               // alert(e.Message);
            }
        }



 <video width="10" height="10" style="margin: 0 !important; padding: 0 !important;
        overflow: hidden;" id="player1" name="mplayer1"  src="http://mysite.com/files/werweB"  type="video/mp4">
    </video>
     <script type="text/javascript">       
        MediaElement('player1', 
        {
            success: function (me) {
                me.play();
            }
        }); 
    </script>

I even tried to do:

mshtml.HTMLDocument doc = (mshtml.HTMLDocument)wb.Document;
var player = doc.getElementById("player1");
player.setAttribute("width", "400");
player.setAttribute("height", "400");

But there is no any visual changes at all...


回答1:


I spent two days searching and this is what I found:

All you have to do is add the following meta tag to your HTML:

<meta http-equiv="X-UA-Compatible" content="IE=9" >


来源:https://stackoverflow.com/questions/14630528/cannot-change-video-tag-size-via-invokescript-of-wpf-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!