View Full Version : Cross-browser print button script help

01-30-2006, 05:40 PM
I have installed this script and it's working ok but when I try to validate my code using W3C validator I run into some errors. Does anyone know how I can get this script to NOT produce errors in W3C?

Here are my errors....

Line 59 column 125: end tag for element "OBJECT" which is not open.

The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

If this error occured in a script section of your document, you should probably read this FAQ entry.

Error Line 70 column 108: end tag for element "FORM" which is not open.
...me="Print" onClick="printit()"></form>');

And here is the code itself....

<SCRIPT Language="Javascript" type="text/javascript">

This script is written by Eric (Webcrawl@usa.net)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com

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 Language="Javascript" type="text/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>');

01-30-2006, 05:46 PM
You evidently didn't read the provided link.
Replace / with \/ in tags in strings.

01-30-2006, 06:52 PM
:eek: DOH! my bad... I'm running on automatic pilot today. Thanx :blush: