try catch一下,不允交互就会有错被catch到

解决方案 »

  1.   

    "而你们在说什么呢?"
    ----拒绝交互的话,创建对象会失败,可以catch到
      

  2.   

    同意JK,如:<script type="text/javascript">
        function word_onclick()
        {
          var oWD = new ActiveXObject("Word.Application");
          var oDC = oWD.Documents.Add("",0,1);
          var oRange =oDC.Range(0,1);
          var sel = document.body.createTextRange();  
          sel.moveToElementText(content);
          sel.select();
          sel.execCommand("Copy");
          oRange.Paste();
          oWD.Application.Visible = true;
        }
    </script>
    <div id="content">
    <h1 style="color:red;">hello,world!</h1>
    </div>
    <button onclick="try{word_onclick()}catch(e){alert('abort!')};">export to word</button>
      

  3.   

    5楼的错了,try中建立active,提示true,catch中提示false,就可以知道点了接受没有了。