简体   繁体   English

使用CDHtmlDialog(MFC)进行JavaScript注入

[英]Javascript injection with CDHtmlDialog (MFC)

Does someone have an example of how to inject Javascript variables with CDHtmlDialog? 有人有示例如何使用CDHtmlDialog注入Javascript变量吗? There don't appear to be any readily available solutions using Google or MSDN. 使用Google或MSDN似乎没有任何可用的解决方案。 Assume that "window.external" is not available within the HTML. 假定“ window.external”在HTML中不可用。

The way you get IHTMLDocument2 is CDHtmlDialog::GetDHtmlDocument. 您获取IHTMLDocument2的方法是CDHtmlDialog :: GetDHtmlDocument。 You need to wait for DocumentComplete before accessing the document. 您需要等待DocumentComplete才能访问文档。 Doing it early may not work . 尽早做可能不起作用

The way you call script is through the IHTMLWindow2 interface . 调用脚本的方法是通过IHTMLWindow2接口 You get the window via IHTMLDocument2::parentWindow property. 您可以通过IHTMLDocument2 :: parentWindow属性获取窗口。 Just declare a variable in the jscript you execute. 只需在执行的jscript中声明一个变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM