Home  >  Q&A  >  body text

Event triggered when switching from b page tab to a page tab

Maybe there are multiple tab pages opened in the browser. How to get the event when the user switches back to the specified page, such as the tab of page a? And execute the specified js?

欧阳克欧阳克2690 days ago1005

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-06-08 11:05:13

    1. If it is a Chrome plug-in, there is a related API

    2. Your own web page. You can try focus event

    window.addEventListener('focus', function () {});

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-08 11:05:13

    Click to switch, and then switch the page. At this time, there are two event attributes, the onunload and onbeforeunload events will be called,

    reply
    0
  • Cancelreply