I am calling a javascript function in a button in aspx page like
OnClientClick= "printText(document.getElementById('PrintPayslipPart').innerHTML)"
and function is;
function printText(elem)
{
PrintPaySlip = window.open('RP_PrintPaySlip.html','PrintPaySlip','toolbar=no,menubar=yes,width=1000, Height = 700, resizable=yes,scrollbar=Yes');
PrintPaySlip.document.open();
PrintPaySlip.document.write("<html><head>");
PrintPaySlip.document.write("</head><body onload='print()'>");
PrintPaySlip.document.write(elem);
PrintPaySlip.document.write("</body></html>");
PrintPaySlip.document.close();
}
I am using .net 3.5 and ajaxcontrolltoolkit 3.5.40412.2
When cl开发者_开发问答icking on button the error shows as "Microsoft JScript runtime error: Object required".
My guess is that either
PrintPayslipPartis not a valid id, and so thegetElementByIdreturns null.PrintPaySlip is not a global variable, and your environment doesn't allow it to be implicitly defined, which could be solved by declaring it local using
varvar PrintPaySlip = window.open(...);
The second one seems more likely.
HTH
first thing i will suggest to you is have Firefox with error console installed and then test the site. At least it can help you find what exactly error is instead of "Microsoft JScript runtime error"
Trust me but Firefox + FireBug + Error Console make life much better for Web (JS) developer.
加载中,请稍侯......
精彩评论