AV1611 Posted October 7, 2008 Share Posted October 7, 2008 Trying to validate a page but get this error: (NOTE: I don't know js) Error Line 46, Column 120: document type does not allow element "object" here . …8856F961-340A-11D0-A96B-00C04FD705A2"></object>'; Here is the relevant part of the code - I put a print button on screen but use css to suppress the print screen button <p class="display_only" style="text-align: center;"> <script type="text/javascript" language="Javascript"> // This Script puts a Print Screen Button on the page function printit(){ if (window.print) { window.print() ; } else { var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>'; document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "; } } </script> <script type="text/javascript" language="Javascript"> var NS = (navigator.appName == "Netscape"); var VERSION = parseInt(navigator.appVersion); if (VERSION > 3) { document.write('<form><input type="button" value="Print this Page" name="Print" onClick="printit()"></form>'); } </script> </p> Quote Link to comment Share on other sites More sharing options...
ScotDiddle Posted October 8, 2008 Share Posted October 8, 2008 AV1611, I wrapped <html> tags around your code and it worked without error on IE7 and Firefox 3.0.3; Scot L. Diddle. Richmond VA <html> <body> <p class="display_only" style="text-align: center;"> <script type="text/javascript" language="Javascript"> // This Script puts a Print Screen Button on the page function printit(){ if (window.print) { alert('Hi Mom'); window.print() ; } else { var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>'; document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "; } } </script> <script type="text/javascript" language="Javascript"> var NS = (navigator.appName == "Netscape"); var VERSION = parseInt(navigator.appVersion); alert(VERSION); if (VERSION > 3) { document.write('<form><input type="button" value="Print this Page" name="Print" onClick="printit()"></form>'); } </script> </p> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.