Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2008
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    This print page function needs a tweak - anyone game?

    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/...experience.php

    Anyone know how to tweak it?

    Cheers

    Shaun

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,480
    Thanks
    6
    Thanked 981 Times in 954 Posts
    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”. 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:

    Code:
    <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.

  • #3
    New Coder
    Join Date
    Jan 2008
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by bigbadroo; 02-12-2008 at 12:29 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •