Google Answers Logo
View Question
 
Q: [Question] execScript function ( No Answer,   1 Comment )
Question  
Subject: [Question] execScript function
Category: Computers
Asked by: hareum-ga
List Price: $5.00
Posted: 06 May 2004 09:39 PDT
Expires: 06 May 2004 17:40 PDT
Question ID: 342114
Hello!!!
I'm a computer progaram engineer from korea.
I develop the application with MFC.
I have a trouble with using IHTMLWindow2 class...
The execscript function do a javascript function sucessfully.
The javascript funtion of HTML or ASP file.
But the third parametar which represents the return value of script
function did not represents the value.
The VARIANT value always VT_EMPTY.
I have no idea why it's value is always VT_EMPTY.
I show you my MFC and javascript code.

// MFC Function
void
CTestDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	IHTMLDocument2* pCtrl=(IHTMLDocument2*)m_oMainDlg.m_pWebCtrl->GetHtmlDocument();
	IHTMLWindow2 *pWindow=(IHTMLWindow2*)NULL;
	pCtrl->get_parentWindow(&pWindow);

	BSTR strSript;
	BSTR strLanguage;
	strSript=L"Javascript:OnChat(\"[Julia]\", \"Hello!!!\");";
	strLanguage=L"JavaScript";
	VARIANT nResult;
	HRESULT hResult;
	hResult=pWindow->execScript(strSript, strLanguage, &nResult);
			// the value of nResult is always VT_EMPTY...
}

// HTML source

<html>
<head>
<script language="JavaScript">
function OnChat(strUser, strMessage)
{
	var RetVal=new InitArray(2);
	RetVal[0]=DecoMessage(strUser);
	RetVal[1]=DecoMessage(strMessage);
	AddMessage(RetVal);

	var strmsg;
	strmsg="Test";
	return strmsg;
}
</script>
</head>

<body>
</body>
<html>
Answer  
There is no answer at this time.

Comments  
Subject: Re: [Question] execScript function
From: stolis-ga on 06 May 2004 10:03 PDT
 
"This method always returns VT_EMPTY."

According to Microsoft's documentation:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/ifaces/window2/execscript.asp


I believe you should be testing for S_OK in hResult, not nResult.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy