从 C# 通过 mshtml 调用 ActionScript (Flash) 方法
我使用 WPF 中的 WebBrowser 组件。我从 Internet 加载一个页面,然后访问 Document 属性来调用我的脚本。不幸的是,调用脚本不能按我的需要工作。当我调用 JavaScript 中存在的 JavaScript 方法时,它工作得很好,但是当我需要访问一些通过 Flash 提供的方法时,我遇到了问题。
document.parentWindow.execScript("document.getElementById('swfObject').methodFromActionScript();", "JavaScript");
我在浏览器中遇到异常,对象不支持此属性或方法。在 C# 中,我从 HRESULT: 0x80020101 中得到异常
,但是当我尝试在常规浏览器(如 IE 或 Chrome)中启动此代码时,将其传递到 URL 中,以便执行代码并看到结果。
也许是一些信任模式问题或其他什么可能拒绝访问 Flash 属性和方法?
顺便说一句:var allowedScriptAccess 设置为始终。
谢谢你的帮助。
I use the WebBrowser component from WPF. I load there a page from Internet and I access the Document property to call my scripts. Unfortunately calling scripts don't work as I need. When I am calling JavaScript methods which exist in JavaScript so it works great but when I need access some methods which are available through Flash so I have problems.
document.parentWindow.execScript("document.getElementById('swfObject').methodFromActionScript();", "JavaScript");
I get an exception in the browser Object doesn't support this property or method. In C# I get Exception from HRESULT: 0x80020101
But when I try launch this code in a regular browser as IE or Chrome by passing it into URL so the code is executed and I see results.
Maybe some trustmode issues or what else could deny access to Flash properties and methods?
BTW: The var allowScriptAccess is set to always.
Thank you for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我发现了一个问题。在此 execScript 之前。我正在对 DOM 进行一些修改并移动元素,显然这已经破坏了 DOM,所以我无法调用 swfObject,因为在移动过程中它以某种方式被修改并丢失了通过 ActionScript 导出的属性和方法。
Ok, I've found an issue. Before this execScript. I was doing some modification of DOM and moving elements and apparently this has broken DOM so I couldn't call swfObject because during moving it was somehow modified and lost its properties and methods which were exported via ActionScript.