Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Urgent ....... handling close button event of the browser

Urgent ....... handling close button event of the browser

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netbeta-testinghelptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krishsenthilraj
    wrote on last edited by
    #1

    hi all, i am doing a web application project using asp.net 2.0(vb). i need to handle a scenario, when the user clicks on the browser's X button i need to prompt them with a popup message . to handle this i have used the following code --------------------------------------------------------------------------- function HandleOnClose() { if (event.clientY < 0) { event.returnValue = 'Are you sure you want to leave the page?'; } } ----------------------------------------------------------------------------------- it prompts the user with Ok and CANCEL button Message box. when the user click the CANCEL button the page is not closed. But if the user clicks on the OK button the window automatically closed. Instead what i need to do is I have to open a popup window asking the user to fillup a feedback form when the user clicks on the OK button. When the user submits the feedback the page should be closed. can any one tell me how to handle the OK button click event on the above code to achieve my task. Or if u know some other way help me..... thank you all in advance Regards Senthilraj K

    S S 2 Replies Last reply
    0
    • K krishsenthilraj

      hi all, i am doing a web application project using asp.net 2.0(vb). i need to handle a scenario, when the user clicks on the browser's X button i need to prompt them with a popup message . to handle this i have used the following code --------------------------------------------------------------------------- function HandleOnClose() { if (event.clientY < 0) { event.returnValue = 'Are you sure you want to leave the page?'; } } ----------------------------------------------------------------------------------- it prompts the user with Ok and CANCEL button Message box. when the user click the CANCEL button the page is not closed. But if the user clicks on the OK button the window automatically closed. Instead what i need to do is I have to open a popup window asking the user to fillup a feedback form when the user clicks on the OK button. When the user submits the feedback the page should be closed. can any one tell me how to handle the OK button click event on the above code to achieve my task. Or if u know some other way help me..... thank you all in advance Regards Senthilraj K

      S Offline
      S Offline
      Sylvester george
      wrote on last edited by
      #2

      function unloadfun() { if (window.event.clientX < 0 && window.event.clientY < 0) { alert("in"); } } call this method in

      Regards, Sylvester G sylvester_g_m@yahoo.com

      1 Reply Last reply
      0
      • K krishsenthilraj

        hi all, i am doing a web application project using asp.net 2.0(vb). i need to handle a scenario, when the user clicks on the browser's X button i need to prompt them with a popup message . to handle this i have used the following code --------------------------------------------------------------------------- function HandleOnClose() { if (event.clientY < 0) { event.returnValue = 'Are you sure you want to leave the page?'; } } ----------------------------------------------------------------------------------- it prompts the user with Ok and CANCEL button Message box. when the user click the CANCEL button the page is not closed. But if the user clicks on the OK button the window automatically closed. Instead what i need to do is I have to open a popup window asking the user to fillup a feedback form when the user clicks on the OK button. When the user submits the feedback the page should be closed. can any one tell me how to handle the OK button click event on the above code to achieve my task. Or if u know some other way help me..... thank you all in advance Regards Senthilraj K

        S Offline
        S Offline
        Sandeep Akhare
        wrote on last edited by
        #3

        Hi Friend i think calling javascript from unload function will have no meaning as you can't do anything as the page is unload event use onbeforeunload event there you have chance Check this code i just tried and it working fine function SomeFunctoin() { here i am checking 2 conditions if(window.event.clientX > 500 && window.event.clientY < 0 || window.event.clientX > 1000 && window.event.clientY < 0) { var bool = confirm("Do you really want to close this window "); if(bool) { // do the things that you want to do if user want to close the window return true; } else { // do the things that when user don't want to close he window return false; } } call this function from lt body onbeforeunload="return SomeFunctoin()"gt -- modified at 4:41 Wednesday 20th June, 2007

        Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

        K 1 Reply Last reply
        0
        • S Sandeep Akhare

          Hi Friend i think calling javascript from unload function will have no meaning as you can't do anything as the page is unload event use onbeforeunload event there you have chance Check this code i just tried and it working fine function SomeFunctoin() { here i am checking 2 conditions if(window.event.clientX > 500 && window.event.clientY < 0 || window.event.clientX > 1000 && window.event.clientY < 0) { var bool = confirm("Do you really want to close this window "); if(bool) { // do the things that you want to do if user want to close the window return true; } else { // do the things that when user don't want to close he window return false; } } call this function from lt body onbeforeunload="return SomeFunctoin()"gt -- modified at 4:41 Wednesday 20th June, 2007

          Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

          K Offline
          K Offline
          krishsenthilraj
          wrote on last edited by
          #4

          hi Sandeep , i tried your code.its working finw for the if loop. i.e if(bool) { // do the things that you want to do if user want to close the window return true; } but its not working fine for else part. what i need to do is when they click cancel button in the confirm message box, i need to be in the same page.but the code closes the window for cancel option also. give me the solution. thanks Regards Senthilraj

          K 1 Reply Last reply
          0
          • K krishsenthilraj

            hi Sandeep , i tried your code.its working finw for the if loop. i.e if(bool) { // do the things that you want to do if user want to close the window return true; } but its not working fine for else part. what i need to do is when they click cancel button in the confirm message box, i need to be in the same page.but the code closes the window for cancel option also. give me the solution. thanks Regards Senthilraj

            K Offline
            K Offline
            krishsenthilraj
            wrote on last edited by
            #5

            hi all, i implemented the concept. we raised the issue to client and we changed the way of implementing it thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups