2.2.6.9.1 DhtmlControl::CallJavaScript


Version

Minimum Origin Version Required: Origin 2017 SR0

Description

Invoke JavaScript function by name.

Syntax

BOOL CallJavaScript( LPCTSTR lpcszFunc )

Parameters

lpcszFunc
[input] The name of the JavaScript function

Return

Returns TRUE on success, FALSE on failure.

Examples

JavaScript:

<script>
	function LineMove() {
                var XValue = document.getElementById("X");
                XValue.value = window.external.ExtCall("GetXValue");
	}
</script>

Labtalk:

line_move($(this.X))

OriginC:

class LTcallJSDlg: public HTMLDlg
{
public:
	void LineMove(double dVal)
	{
		m_dXValue = dVal;
		m_dhtml.CallJavaScript("LineMove");
	}
	double GetXValue()
	{
		return m_dXValue;
	}
}
BEGIN_DISPATCH_MAP(LTcallJSDlg, HTMLDlg)
	DISP_FUNCTION(LTcallJSDlg, GetXValue, VTS_I4, VTS_VOID)
END_DISPATCH_MAP

static LTcallJSDlg* s_pDlg = NULL;

void LTcallJSDlgHTML()
{
	LTcallJSDlg dlg;
	s_pDlg = &dlg;
	dlg.DoModalEx(GetWindow());
	s_pDlg = NULL;
}

void line_move(double dVal)
{
	if ( s_pDlg )
	{
		s_pDlg->LineMove(dVal);
	}
}

Remark

See Also

Header to Included

Control.h