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
https://forums.phpfreaks.com/topic/127435-script-wont-validate/
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
https://forums.phpfreaks.com/topic/127435-script-wont-validate/#findComment-659918
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.