ActiveX×é¼þÓëJavaScript½»»¥
1£®ÔÚCOM×é¼þÖе÷ÓÃJavaScriptº¯Êý
// Á¬½Óµã·½Ê½Ò³Ãæjavascript½Å±¾
<object classid="CLSID:B568F111-DFE4-4944-B67F-0728AB2AB30F"
id="testCom" VIEWASTEXT></object>
<script language="JavaScript" for="testCom" event="staTe(s)">
alert("State(" + s + ")");
return 123;
</script>
<script language="JavaScript">
testCom.FireStateEvent("Hello");
</script>
// ʼþÊôÐÔ·½Ê½Ò³Ãæjavascript½Å±¾
function onState(s){
alert("onState(" + s + ")");
return 456;
}
var o = new ActiveXObject("TestATL.TestCom");
o.onstaTe=onState;
o.FireStateEvent("Hello");
// Com×é¼þVC7.1 ATL´úÂë
__interface _ITestComEvents{
[id(1), helpstring("Stateʼþ")] HRESULT State([in] BSTR str);
};
__event __interface _ITestComEvents;
IDispatchPtr m_onState; // ʼþÊôÐÔ
STDMETHOD(get_onState)(IDispatch** pVal) {
*pVal = m_onState;
return S_OK;
};
STDMETHOD(put_onState)(IDispatch* newVal) {
m_onState = newVal;
return S_OK;
};
STDMETHOD(FireStateEvent)(BSTR str) {
__raise State(str); // ¼¤·¢Á¬½Óµãʼþ
CComVariant result;
CComVariant avarParams[1] = {str};
DISPPARAMS dispParams = {avarParams, NULL, 1, 0};
&nb
Ïà¹ØÎĵµ£º
ÏÖÔÚµÄRIA£¨Rich Internet
applications)Ô½À´Ô½Á÷ÐУ¬JavascriptÔÚÕâÖмäÆðµ½Á˲»¿ÉºöÊÓµÄ×÷Óã¬Õâ¸öÊÀ½çÉÏ£¬ÍêÈ«²»ÓÃJSµÄÍøÕ¾Ó¦¸ÃºÜÉÙÁË£¬Ò»Ð©Óû§ÌåÑéºÃ
µÄÍøÕ¾£¬´ó¶à²ÉÓÃÁËFlash»òÕßJS£¬¶øÒÔJS¾Ó¶à¡£±ÈÈçÏñQunar£¬¾ÍÊÇÒÔJavascript +
AjaxΪÖ÷µÄÍøÕ¾£¬Ç°Ì¨Ò³ÃæÖ÷ÒªÊÇHTML£¬ºǫ́Éú³ÉJSONÊý¾Ý¡£ÔÙ±ÈÈç˵Ajax×îÔç´ó¹ ......
µÚÎåÕ Êý×é JavaScriptµÄÊý×éÒ²ÊÇÒ»¸ö±È½ÏÓÐÒâ˼µÄÖ÷Ì⣬ËäÈ»ÃûΪÊý×é(Array)£¬µ«ÊǸù¾ÝÊý×é¶ÔÏóÉϵķ½·¨À´¿´£¬¸üÏñÊǽ«ºÜ¶à¶«Î÷»ìÔÚÔÚÒ»ÆðµÄ½á¹û¡£¶ø´«Í³µÄ³ÌÐòÉè¼ÆÓïÑÔÈçC/JavaÖУ¬Êý×éÄÚµÄÔªËØÐèÒª¾ßÓÐÏàͬµÄÊý¾ÝÀàÐÍ£¬¶ø×÷ΪÈõÀàÐ͵ÄJavaScript£¬ÔòûÓÐÕâ¸öÏÞÖÆ£¬ÊÂʵÉÏ£¬JavaScriptµÄͬһ¸öÊý×éÖУ¬¿ÉÒÔÓи÷ÖÖÍêÈ«²»Í ......
<html xmlns="http://www.w3.org/1999/xhtml" >
<head >
<title></title>
</head>
<body>
<form id="form1">
<div>
& ......