Results 1 to 6 of 6

Thread: Back Button JS

  1. #1
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default Back Button JS

    Does anyone have a quick script that would pop an alert that you will lose any unsaved information when they click on the browser back button?

    Much appreciated!
    Thank you,
    Lynne Hanson
    RL Hanson-Online

  2. #2
    QHF's Avatar
    QHF
    QHF is offline Nearly a Master Glow Jedi
    Join Date
    Jun 2007
    Location
    Wisconsin
    Posts
    131

    Default

    This may be what your looking for I'm not a programmer but it seems to be on point.
    QHF

    "This is an Emergency?"

  3. #3
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    Heres what I use:
    HTML Code:
    <input type="button" value="Go Back" onClick="history.go(-1)">

  4. #4
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    Oh crap .... I am getting old - That isn't even close to what you asked for! Sorry....

  5. #5
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default

    Quote Originally Posted by jmarcv View Post
    Oh crap .... I am getting old - That isn't even close to what you asked for! Sorry....
    I just kinda chuckled... you're usually right on JM so I figured it was just a matter of time! lol
    Thank you,
    Lynne Hanson
    RL Hanson-Online

  6. #6
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default

    I hear this one works:

    Code:
    <script language="JavaScript" type="text/JavaScript">
    var postback = false;
    window.onbeforeunload = confirmExit;
    
    
    function confirmExit() {
    if (postback == true) {
    event.cancelBubble = true;
    }
    else
    return 'NOTE!!: Please save before leaving this page. Your information will be lost if you choose to navigate away from this page.';
    }
    </script>
    
    
    <asp:Button runat="server" ID="btnDoRegisteredPostback" Text="DoRegisteredPostBack"
    OnClientClick="postback=true;return true;" />
    <asp:Button runat="server" ID="btnDoPostback" Text="LeavePage"�
    onclick="btnDoPostback_Click"� />
    Thank you,
    Lynne Hanson
    RL Hanson-Online

Similar Threads

  1. Emails bouncing back
    By Gary Lewis in forum WHM, Resellers, VPS and Dedicated Hosting Topics
    Replies: 15
    Last Post: 03-10-2009, 10:54 PM
  2. How to back up website?
    By cornnfedd in forum General Support
    Replies: 4
    Last Post: 09-23-2008, 07:53 PM
  3. HTML Web Form Submit Button
    By amie654 in forum Web Design
    Replies: 3
    Last Post: 08-12-2008, 06:45 PM
  4. Back to drywall :)
    By rlhanson in forum General Chit-Chat
    Replies: 7
    Last Post: 05-22-2008, 12:27 AM
  5. Why do i gain weight at the back of my hips!
    By Nefrit in forum General Chit-Chat
    Replies: 7
    Last Post: 03-11-2008, 07:54 AM

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14