...

View Full Version : This print page function needs a tweak - anyone game?



bigbadroo
02-12-2008, 12:52 PM
Hi

I have this little function that opens a new page, and automatically opens the user's printer window. It works fine in IE, but in FF I get the following error:

'The page was replaced when you were trying to print. Please try again.'

Here's the code:

<a href="#" onclick="newwin=window.open('http://www.bigbadroo.com.au/popbeat/Website/acts/tribute_acts/tom_jones_experience/australian_tom_jones_experience_print.html');if(newwin)newwin.print();" value="Print"><p>Print Artist Fact Sheet</p>(A4 size)</a>

Here's a link to the page to see what's happening (not ready for public viewing):

http://www.bigbadroo.com.au/popbeat/Website/acts/tribute_acts/tom_jones_experience/australian_tom_jones_experience.php

Anyone know how to tweak it?

Cheers

Shaun

VIPStephan
02-12-2008, 01:06 PM
It works for me. Might be your popup blocker? Anyway, if that’s the case then it might be problematic with other users as well so the best way would be to not open a new window.

Also, your link shouldn’t depend on JavaScript completely. Nowadays we’re working according to a method called “progressive enhancement (http://en.wikipedia.org/wiki/Progressive_enhancement)”. This means we ensure that the site is working without any scripts and those scripts are only enhancements to the site for those devices that support it.

In your case you should put the URL in the href attribute in case people have JS deactivated:


<a href="http://www.bigbadroo.com.au/popbeat/Website/acts/tribute_acts/tom_jones_experience/australian_tom_jones_experience_print.html" onclick="newwin=window.open('http://www.bigbadroo.com.au/popbeat/Website/acts/tribute_acts/tom_jones_experience/australian_tom_jones_experience_print.html');if(newwin)newwin.print(); return false;"><p>Print Artist Fact Sheet</p>(A4 size)</a>

And what’s that value="Print" supposed to be? That’s not valid HTML as far as I know.

bigbadroo
02-12-2008, 01:22 PM
Thanks Stephan

I'm still getting the same error in Firefox, so I'll just put a message for FF users to print it out manually.

Actually, is there a way to make it not invoke the printer dialog box if it's a Firefox browser?

Cheers

S



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum