随着IE11的出现,IHTMLWindow2::execScript()不推荐使用.推荐的方法是使用eval()代替.我通过其C++ COM接口自动化IE,我一直无法找到如何实现这一点.有人能指出我在搜索中明显错过的例子吗?如果无法执行代码eval,那么将JavaScript代码注入到现在execScript不再可用的Internet Explorer实例中的适当方法是什么?
编辑:任何适用于我正在进行的项目的解决方案必须在进程外工作.我没有使用浏览器助手对象(BHO)或任何类型的IE插件.因此,任何涉及无法正确编组交叉过程的接口的解决方案都不适用于我.
我当前的代码适用于iframe之外的元素.我应该如何使用getElementById在iframe中获取元素?我的最终目标是在<body id="tinymce"><p>...</p></body>标签内写文字.我没有使用webBrowser控件 - 这是针对iexplore的外部实例
HTML示例

代码示例
foreach (InternetExplorer ie in new ShellWindowsClass())
{
if (ie.LocationURL.ToString().IndexOf("intranet_site_url") != -1)
{
IWebBrowserApp wb = (IWebBrowserApp)ie;
while (wb.Busy) { Thread.Sleep(100); }
HTMLDocument document = ((HTMLDocument)wb.Document);
// FETCH BY ID
IHTMLElement element;
HTMLInputElementClass hitem;
element = document.getElementById("tinymce");
hitem = (HTMLInputElementClass)element;
hitem.value = first_name;
// FETCH BY ID in IFRAME
IHTMLFramesCollection2 hframes = document.frames;
for (int i = 0; i < hframes.length; i++)
{
object ref_index = i;
IHTMLWindow2 currentFrame = (IHTMLWindow2)hframes.item(ref ref_index);
if …Run Code Online (Sandbox Code Playgroud)