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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile How to create an error message when one closes the window

    I would like to know how to create an error message when someone decides to close my blog!
    For example i am on your blog and you don't want me to go from your blog. So. inorder to make the person to think twice you will create an error message when someone closes your window with the message that you will be providing an better offer!!

    Iam a complete beginner in this!!

    Any Help will be appreciated!!

    Thanks in advance!!

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    I'd rather you didn't - just make your blog more interesting! (If I received this error message I would never come back!)

    Code:
    <body onbeforeunload="alert('Goodbye forever!');" >
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New Coder
    Join Date
    Apr 2011
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post
    Andrew..."onbeforeunload" will work good on all browsers ? Long back I had some problem with Firefox and fixed by a friend.

  • #4
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,335
    Thanks
    5
    Thanked 363 Times in 360 Posts
    uggghhh. Nothing I hate worse than trying to leave a site and a message pops up asking me am I sure I want to leave. Well if I clicked the "X" then YES I'm wanting to leave!

    As Kor said, dont make your visiters annoyed and risk them never coming back just to add some fancy javascript like this. I dont usually go back to sites like this either.
    Teed

  • #5
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    If you still insist on doing this then it works.. as well as can be expected! But not properly in Opera.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

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