Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onAfterPrint

Status
Not open for further replies.

KevinFSI

Programmer
Nov 17, 2000
582
US
I'm hiding the background image from the printer using the onBeforePrint attribute in IE 5+. This works fine, but I'm somehow flubbing up the syntax when trying to put the background image back in onAfterPrint. Do any of you guys see what I've done wrong?
Code:
<LINK REL=&quot;STYLESHEET&quot; TYPE=&quot;text/css&quot; HREF=&quot;eac_style.css&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
	function removebackground()
	{
		//Set the document's background image to null
		document.body.style.background=''
	}

	function revertback()
	{
		//Put the image back
		document.body.style.background='background_1.gif'
	}

	window.onbeforeprint=removebackground
	window.onafterprint=revertback
</SCRIPT>

I can make it work by just reloading the window, but that kinda sucks since the user has gotten to this page via a form, so there is a box that comes up an tells them that the page cannot be refreshed without resubmitting the values etc... It's just an extra click I'd like to eliminate. Kevin
slanek@ssd.fsi.com
 
usually background images aren't printed anyway - Did you have the question about that? if so, how did you do it? (Get the bg to print that is)

But to put it back you will need to fill in the whole thing - like url:('background_1.gif'). since this is how it appears in the style definition.

BB &quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
Yeah, I got it worked out yesterday and tried to post a message that said, &quot;disregard this post,&quot; but it errored out when I tried to submit the post, so I never sent it.

The background images thing was in Tools -- Internet Options -- Advanced -- Printing. I guess I never noticed that one.

You're right though. I wanted the bg colors in the table rows to print out, but not the page background. All I had to do was remove the page background image before print then replace it after print. I wasn't putting &quot;url()&quot; in there.

Thanks for the response though. Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top