Jump to content

script won't validate


AV1611

Recommended Posts

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.