SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using history.back()

    Anyone give me a hint on this?

    I have a form with a "Print" button on the page. When the user clicks this it doesn't actually print but opens a condensed version of the page, passing the field contents with php.

    On the new (condensed) page I capture the load of the page in js and when it occurs issue the command print(). This works fine.

    But once I've done this (printed) I would like to return to my original form. I've tried

    if (print()) history.back()

    print()
    history.back()

    neither seems to work. As an experiment I put the following code at the bottom of my condensed page that prints...

    <FORM>
    <INPUT type="button" value="Click here to go back" onClick="history.back()">
    </FORM>

    Clicking on the resulting button does exactly what I want... clears the form and returns me to my original.

    I just don't what to
    a) print the form with that button on it
    b) require user input after the printing.

    So... can anyone point me in a way of making history.back() work outside of an onClick construct?

    Thank you very much!

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,871
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Why are you opening a separate copy of the page for printing instead of using a media="print" stylesheet?
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Original form is multi purpose

    The reason I'm not using the media print style sheet is because the original form is multi-purpose.

    When the user needs to print it we only want bits and pieces of the original, not all of it. The second form/page does that reformatting for me.


Bookmarks

Posting Permissions

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