【问题标题】:Accessing HTMLObjectElement from System.Windows.Forms.WebBrowser fails从 System.Windows.Forms.WebBrowser 访问 HTMLObjectElement 失败
【发布时间】:2014-02-20 09:04:49
【问题描述】:

此 HTML 基于之前找到的解决方案 here:

<body>
<object data="C:\Dts\AipDirs\Eg\MarsOutputStore\_AD2_LFBD_000.svg" id="alphasvg" width="100%" height="100%" type="image/svg+xml"></object>
<script>
    var a = document.getElementById("alphasvg");

    alert (a); // Displays [object HTMLObjectElement] when page is loaded into IE on desktop, but [object] when loaded into System.Windows.Forms.WebBrowser

    // it's important to add an load event listener to the object, as it will load the svg doc asynchronously
    a.addEventListener("load",function(){

        alert ("in addEvenetListener for load");       

    },false);
</script>

当我将它加载到在我的桌面上运行的 IE(版本 10)中时,它可以正常工作。但是,当我将它加载到 UserControl 中的 WebBrowser 对象中时,它不起作用 - 警报返回一个不同的对象(请参阅该行的注释),然后它抱怨:

Object doesn't support property or method 'addEventListener'

为什么 WebBrowser 在桌面上的行为不像 IE?

【问题讨论】:

    标签: javascript html .net svg webbrowser-control


    【解决方案1】:

    这似乎解决了它:

    <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    

    WebBrowser 和 IE 对于 Intranet 文档有不同的默认兼容模式,我是从本地文件系统加载 HTML 文件。可能跟这有关系?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-26
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多