易截截图软件、单文件、免安装、纯绿色、仅160KB

ActiveX组件与JavaScript交互

2007-10-24 23:55
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};
        EXCEPINFO excepInfo;
        memset(&excepInfo, 0, sizeof excepInfo);
&nb


相关文档:

JavaScript 如何弹出一个对话框窗口

//定义要打开的对话框页面的地址 一般用action跳转要写明action的地址,如果需要参数,则在后面拼接
var urlDialog = "grpBlackWhiteManageAction.do?act=choiceMessageModel&GrpBWhiteListLevel=0";
//定义要弹出的对话框的模式,dialogWidth宽,dialogHeight高 等等
 var style = "dialogWidth=600px;dialogH ......

IE和Firefox在JavaScript应用中的兼容性

1.document.formName.item("itemName") 问题
说 明:IE下,可以使用document.formName.item("itemName")或document.formName.elements ["elementName"];Firefox下,只能使用document.formName.elements["elementName"].
解决方法:统一使用document.formName.elements["elementName"].
2.集合类对象问题
说明:IE下,可以 ......

javascript基础知识【最详尽】

1 创建脚本块
1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script> 
2 隐藏脚本代码
1: <script language=”JavaScript”>
2: <!--
3: document.write(&ldquo ......

javascript截取路径中的文件名

<!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>
    <meta http-equiv="Content-Type"&nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号