OnbeforeUpload event not firing in chrome

I am using asp.net page, I have called following java script event:
  window.onbeforeunload = doUnload;
      function doUnload() {
                if (!isClose) {
             
              document.getElementById('<%=btnClose.ClientID %>').click();
          }
      }

So what I am trying to achieve is that if user close that page then I want to store some value in database,that's why I have fired button click event. This is working fine on IE11 but not working on chrome, Can you please tell me solutions to fix my problem asap.

Regards,
Sudhanshu
SudhanshumAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dorababu MSenior Software EngineerCommented:
What was isClose value getting here is it false or true? Check by removing that condition and see whether you are able to perform as required. Also when you close the browser application will be stepped so what you are trying to insert to DB?
0
SudhanshumAuthor Commented:
Nothing happening after removing isclose. Yes I am updating in database.
0
Dorababu MSenior Software EngineerCommented:
Does that event fires? check in chrome console by putting break points
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

SudhanshumAuthor Commented:
I am using web applications.
0
Dorababu MSenior Software EngineerCommented:
So what we can debug the javascript in chrome console
0
Leonidas DosasCommented:
Try this:
function doUnload() {
                if (!isClose) {
             
              document.getElementById('<%=btnClose.ClientID %>').click();
          }
      }

window.addEventListener('beforeunload',function(){
  doUnload();
});

Open in new window

0
SudhanshumAuthor Commented:
Hi Leonidas Dosas, Thanks for reply, I tried this also but not working in chrome. is there any way to find open tabs?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SudhanshumAuthor Commented:
not got solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Safari

From novice to tech pro — start learning today.