如何使用vbscript触发javascript函数?

时间:2019-02-08 14:59:23

标签: javascript function vbscript

我正在尝试使用vbscript单击“打印”按钮。但是,它实际上不会触发适当的事件。所以现在我想我需要找出一种调用函数本身的方法。

这是按钮代码:

<input name="ucDetailsAJ1670783$btnPrint" tabindex="-1" class="rbDecorated rbPrimary" id="ucDetailsAJ1670783_btnPrint_input" style="width: 100%; padding-right: 4px; padding-left: 0px;" type="submit" value="Print">

<input name="ucDetailsAJ1670783_btnPrint_ClientState" id="ucDetailsAJ1670783_btnPrint_ClientState" type="hidden" value='{"text":"Print","value":"","checked":false,"target":"","navigateUrl":"","commandName":"","commandArgument":"","autoPostBack":false,"selectedToggleStateIndex":0,"validationGroup":null,"readOnly":false,"primary":false,"enabled":true}' autocomplete="off">

这是打印功能代码:

function btnPrint_OnClientClicking(sender, args)
{

        doPrint();


    return false;
}

function openPopup()
{
    var url = document.location.origin + '/Customized/CustomizedControls/DEAModules/Search/PrintDetails.aspx?RelId=605598&Key=29_117_8_167_19_163_12_121_129_12_163_128_60_154_31_198_70_205_6_230_173_133_82_216_52_56_178_209_108_67_255_205';
        var win = window.open(url, '_blank');
        if (win) win.focus();
}

function doPrint()
{
        var divButtons = document.getElementById('ucDetailsAJ1670783_divButtons');  
        if (divButtons) { divButtons.style.display = 'none'; }

        setTimeout("window.print();", 300);

}

这是我的代码和收到的错误消息(使用vbscript调用javascript函数),我知道我丢失了一些东西:

  

空错误消息

objIE.Document.parentWindow.execScript "doPrint();", "javascript"
  

预期声明

objIE.Document.parentWindow.execScript "doPrint();", "jscript"
  

未终止的字符串常量

objIE.document.parentWindow.execScript "btnPrint_OnClientClicking(sender, args);", "javascript"
  

预期声明

objIE.document.parentWindow.execScript "btnPrint_OnClientClicking();", "javascript"

1 个答案:

答案 0 :(得分:0)

您可能对Internet Explorer 11中的更改​​不满意

  

来自MSHTML Reference - execScript method

     

不再支持[IHTMLWindow2 :: execScript 。从Internet Explorer 11开始,使用eval。有关信息,请参见Compatibility changes。]