search

Home  >  Q&A  >  body text

JS/JQuery detects whether the page is refreshed or closed and performs AJAX requests.

onbeforeunload() and onunload() have been tried, including the AJAX methods provided online.

onbeforeunload(), IE and Chrome support it, but the function cannot be executed. It can only return a prompt string. The onunload() method is not supported by Chorme and the IE effect is not good. Please give me some advice on whether there is a better method.

This is mainly used for users to judge whether they are online or offline. Method to prevent the page from not being logged in after it is closed.

phpcn_u5220phpcn_u52202727 days ago1501

reply all(4)I'll reply

  • ︶ㄣyi個*L

    ︶ㄣyi個*L2017-07-22 16:43:45

    It would be great if I could show you the code

    reply
    0
  • phpcn_u5220

    phpcn_u52202017-07-10 09:49:30

    I solved it with cooking.

    reply
    0
  • PHP中文网

    PHP中文网2017-07-03 09:27:11

    Use websocket long link, the PHP side monitors the socket port number, the session is saved in the database, and the PHP side clears the session record in the database after disconnection.

    reply
    0
  • phpcn_u5220

    phpcn_u52202017-07-03 09:25:49

    Already solved

    reply
    0
  • Cancelreply