自动激活 activex control

微软调整了浏览器activex的策略,在被激活之前不能对他进行操作,没有激活时许多事件被屏蔽

被屏蔽事件如下 

onactivateondragleaveonmouseout
onbeforeactivateondragoveronmouseover
onbeforecopyondragstartonmouseup
onbeforecutondroponmousewheel
onbeforedeactivateonfocusonmove
onbeforepasteonfocusinonmoveend
onbluronfocusoutonmovestart
onclickonhelponpage
oncontextmenuonkeydownonpaste
oncontrolselectonkeypressonresize
oncopyonkeyuponresizeend
oncutonlosecaptureonresizestart
ondblclickonmousedownonscroll
ondeactivateonmouseenteronselectstart
ondragendonmouseleave 
ondragenteronmousemove 

 

解决办法有下面几种(主要是由外部js文件动态载入控件以避免激活)

1.用document.write动态载入(注意不能使用writeln,如果使用writeln将会和直接载入一样要激活)

<!-- HTML File --><html>  <body leftmargin=0 topmargin=0 scroll=no>    <script src="docwrite.js"></script>  </body></html>
// docwrite.jsdocument.write('<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6">');document.write('<param name="URL" value="example.wmv">');document.write('<param name="autoStart" value="-1"></object>');
2.用OuterHtml
<!-- HTML File --><html>  <body>     <div id="embedControlLocation">      <script src="embedControlOuterHTML.js"></script>    </div>  </body></html>
// outerhtml.jsembedControlLocation.outerHTML = '<embed src="examplecontrol">';

 

3.用createElement

<!-- HTML File --><html>  <body>     <div id="DivID">      <script src="createElementExplicit.js"></script>    </div>    </body></html>
// createElementExplicit.jsvar myObject = document.createElement('object');DivID.appendChild(myObject);myObject.width = "200";myObject.height = "100";myObject.classid= "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"; myObject.URL = "example.wmv";myObject.uiMode = "none" ;

 

4.innerHtml

<html><head><script src="external_script.js" language="JScript"></script></head><body><div id="EXAMPLE_DIV_ID">This text will be replaced by the control</div><script language="JScript">CreateControl( "EXAMPLE_DIV_ID","clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6","EXAMPLE_OBJECT_ID", "600", "400", "example.wmv","-1")</script></body></html>

// external_script.jsfunction CreateControl(DivID, CLSID, ObjectID,                       WIDTH, HEIGHT, URL, AUTOSTART){  var d = document.getElementById(DivID);  d.innerHTML =     '<object classid=' + CLSID + ' id=' + ObjectID +     ' width=' + WIDTH + ' height=' + HEIGHT +'>    <param name="URL" value=' + URL + '>    <param name="autoStart" value=' + AUTOSTART + '/>';}
 
更多信息参见
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp
 
codeproject上有人已经包装了现成的服务器控件用来做这件事情
http://www.codeproject.com/aspnet/AutoActivateControl.asp 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值