I want the Browser Tab Focus and Blur Event using HostListener.
First Import HostListener
in your Component
import { HostListener } from '@angular/core';
Then put this code to get Tab Focus and Blur Event
export class AppComponent {
@HostListener('window:focus', ['$event'])
onFocus(event: FocusEvent): void {
// Do something
}
@HostListener('window:blur', ['$event'])
onBlur(event: FocusEvent): void {
// Do something
}
........
.....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With