I can successfully call JS function in the main page from VC++, but when I call the JS function in frame, GetIDsOfNames() return DISP_E_UNKNOWNNAME. The question can be describe as below:
main page is
INDEX.HTM, loaded in webbrowser control, src:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample</title>
<script type="text/javascript">
function
FuncMain()
{
alert("Main Page Function Called!");
}
</script>
</head>
<body>
<iframe id="page_test1" width="100%" height="100%" src="test1.htm" frameborder="0" scrolling="no"></iframe>
<iframe id="page_test2" width="100%" height="100%" src="test2.htm" frameborder="0" scrolling="no"></iframe>
</body>
</html>
test1.htm src:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
Test1 frame page
</body>
</html>
test2.htm src:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function
showAlert(x)
{
alert(x);
}
function callVC()
{
window.external.VCFuncTest();
}
</script>
</head>
<body>
Test2 frame page
Test
</body>
</html>
in VC++:
VC++ code can call JS functions by CWebPage class, I found it here:
JavaScript call from C++
in my VC project, webPage.CallJScript(_T("FuncMain")) succeeded!
webPage.CallJScript(_T("page_test2.showAlert") failed, the GetIDsOfNames() return DISP_E_UNKNOWNNAME.
BTW, webPage.CallJScript(_T("showAlert") also failed! Same error.
any help?
Best Regards!