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
Ïà¹ØÎĵµ£º
JavaScript µÄ³É¹¦ÈÃÈ˽ò½òÀÖµÀ£¬Îª Web ÍøÒ³±àд JavaScript ´úÂëÒѾÊÇËùÓÐ Web Éè¼ÆʦµÄ»ù±¾¹¦£¬ÕâÃÅÓÐȤµÄÓïÑÔÔ̲Ø×ÅÐí¶à²»ÎªÈËÊìÖªµÄ¶«Î÷£¬¼´Ê¹¶àÄêµÄ JavaScript ³ÌÐòÔ±£¬Ò²Î´ÄÜÍêÈ«³Ô͸¡£±¾ÎÄ´Ó7¸ö·½Ãæ½²Êö JavaScript ÖÐÄÇЩÄã²»ºÜÊìÖªµ«·Ç³£ÊµÓõļ¼ÇÉ¡£
¼òÂÔÓï¾ä
JavaScript ¿ÉÒÔʹÓüòÂÔÓï¾ä¿ìËÙ´´½¨¶ÔÏóºÍÊý× ......
JavaScript µÄ³É¹¦ÈÃÈ˽ò½òÀÖµÀ£¬Îª Web ÍøÒ³±àд JavaScript ´úÂëÒѾÊÇËùÓÐ Web Éè¼ÆʦµÄ»ù±¾¹¦£¬ÕâÃÅÓÐȤµÄÓïÑÔÔ̲Ø×ÅÐí¶à²»ÎªÈËÊìÖªµÄ¶«Î÷£¬¼´Ê¹¶àÄêµÄ JavaScript ³ÌÐòÔ±£¬Ò²Î´ÄÜÍêÈ«³Ô͸¡£±¾ÎÄ´Ó7¸ö·½Ãæ½²Êö JavaScript ÖÐÄÇЩÄã²»ºÜÊìÖªµ«·Ç³£ÊµÓõļ¼ÇÉ¡£
¼òÂÔÓï¾ä
JavaScript ¿ÉÒÔʹÓüòÂÔÓï¾ä¿ìËÙ´´½¨¶ÔÏóºÍÊý× ......
http://news.csdn.net/a/20100424/218105.html
JavaScript µÄ³É¹¦ÈÃÈ˽ò½òÀÖµÀ£¬Îª Web ÍøÒ³±àд JavaScript ´úÂëÒѾÊÇËùÓÐ Web Éè¼ÆʦµÄ»ù±¾¹¦£¬ÕâÃÅÓÐȤµÄÓïÑÔÔ̲Ø×ÅÐí¶à²»ÎªÈËÊìÖªµÄ¶«Î÷£¬¼´Ê¹¶àÄêµÄ JavaScript ³ÌÐòÔ±£¬Ò²Î´ÄÜÍêÈ«³Ô͸¡£±¾ÎÄ´Ó7¸ö·½Ãæ½²Êö JavaScript ÖÐÄÇЩÄã²»ºÜÊìÖªµ«·Ç³£ÊµÓõļ¼ÇÉ¡£
¼òÂÔÓï¾ä
......
JavaScript¾ÍÕâô»ØÊÂ1£º»ù´¡ÖªÊ¶
1 ´´½¨½Å±¾¿é
1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script>
2 Òþ²Ø½Å±¾´úÂë
1: <script language=”JavaScript”>
2: <!--
3: document.write(“Hello”);
4: // -->
5: </scri ......