Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
nirene
Yak Posting Veteran
98 Posts |
Posted - 2007-12-21 : 02:22:12
|
Hai, I get an error when I call a javascript script function to open a new window.ErrorMicrosoft JScript runtime error: 'document' is null or not an objectScript function PrintMe(){ var NewWin = window.open("","","directories=no,menubar=no,resizable=no,scrollbars=yes,location=no,titlebar=no,toolbar=no"); NewWin.document.open(); NewWin.document.writeln('<html>'); NewWin.document.writeln(' <head>'); NewWin.document.writeln(' <link href="cssClassPrint.css" rel="stylesheet" type="text/css"/>'); NewWin.document.writeln(' </head>'); NewWin.document.writeln(' <body topmargin=0 rightmargin=0 bottommargin=0 leftmargin=0>'); NewWin.document.writeln(PrintDiv.innerHTML); NewWin.document.writeln('<input type=button Value="Print" onclick="window.print();" class="noprint">'); //NewWin.document.writeln('<input type=button Value="Print" onclick="document.frames[0].print();" class="noprint">'); NewWin.document.writeln(' </body>'); NewWin.document.writeln('</html>'); NewWin.document.close();}Code Behind code is thisRegisterStartupScript("X", "<script>PrintMe()</script>")Held up with this error for long.Nirene |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-12-21 : 20:56:14
|
Does the popup open? Perhaps you have a popup blocker that stops the window opening and then document will be null. Add a check after you open the window and only run the code if NewWin is not null. |
|
|
|
|
|