C#.NET Webbrowser-Control-Javascript方法ResizeTo不起作用. [英] C# .NET Webbrowser-Control - Javascript Method ResizeTo Does Not Work.
问题描述
嘿!
我正在使用Webbrowser遇到问题-.NET Framework(4.6.1)中的控件.
I‘m experiencing an Issue using the Webbrowser-control from the .NET Framework (4.6.1).
使用简单的JavaScript(窗口.ResizeTo)将窗口调整为特定大小在IE 11中可以正常工作.但是,它在Webbrowser-Control中不起作用!
我已经在指定使用的IE版本通过浏览器控件 FEATURE_BROWSER_EMULATION IE 11的注册表项(将密钥设置为11000).
I am already specifying the used IE version of the webbrowser control via the FEATURE_BROWSER_EMULATION Registry Key to IE 11 (set key to 11000).
这是我用于测试的JS代码:
<!DOCTYPEhtml>
< html>
< body>
<!DOCTYPEhtml>
<html>
<body>
< button onclick =" resizeWin()>调整大小窗口</button>
< script>
函数resizeWin(){
window.resizeTo(250,250);
}
</script>
</body>
</html>
<button onclick="resizeWin()">Resize window</button>
<script>
function resizeWin() {
window.resizeTo(250, 250);
}
</script>
</body>
</html>
对于Visual Studio/C#部分,只需创建一个新的Visual Studio项目,然后在窗口中添加Webbrowser组件.使用上面的代码将URL设置为HTML文档.请参阅与IE 11相比,它如何工作.
对于如何解决此问题的任何想法或解决方法的建议,我将不胜感激.
问候,
帕特里克
推荐答案
如果要更改控件或窗体的大小,是否尝试过C#功能,例如 "webBrowser1.Size =新大小(250、250)" ?我认为JavaScript函数仅适用于单独的浏览器框架.
If you want to change the size of the control or form, have you tried the C# features, such as ‘webBrowser1.Size = new Size(250, 250)’? I think that the JavaScript function is only for separate browser frames.
这篇关于C#.NET Webbrowser-Control-Javascript方法ResizeTo不起作用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!