When starting chrome with full screen, exiting full screen on angular does not work.
html:
<hello name="{{ name }}"></hello>
<a href="https://angular-go-full-screen-f11-key.stackblitz.io" target="_blank" style="display: block;">
Open in new window
</a>
<button (click)="openFullscreen()">Go full screen</button>
<button (click)="closeFullscreen()">Exit full screen</button>
ts:
import { DOCUMENT } from '@angular/common';
import { Component, Inject, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
constructor(@Inject(DOCUMENT) private document: any) {}
elem;
ngOnInit() {
this.elem = document.documentElement;
}
openFullscreen() {
if (this.elem.requestFullscreen) {
this.elem.requestFullscreen();
} else if (this.elem.mozRequestFullScreen) {
/* Firefox */
this.elem.mozRequestFullScreen();
} else if (this.elem.webkitRequestFullscreen) {
/* Chrome, Safari and Opera */
this.elem.webkitRequestFullscreen();
} else if (this.elem.msRequestFullscreen) {
/* IE/Edge */
this.elem.msRequestFullscreen();
}
}
/* Close fullscreen */
closeFullscreen() {
if (document.exitFullscreen) {
this.document.exitFullscreen();
} else if (this.document.mozCancelFullScreen) {
/* Firefox */
this.document.mozCancelFullScreen();
} else if (this.document.webkitExitFullscreen) {
/* Chrome, Safari and Opera */
this.document.webkitExitFullscreen();
} else if (this.document.msExitFullscreen) {
/* IE/Edge */
this.document.msExitFullscreen();
}
}
}
This is stackblitz sample.
When opening the page above (and "open in new window"), the "Go full screen" and "Exit full screen" buttons work.
But when opening this page with full screen option as below, the "Exit full screen" button does not work.
chrome.exe --start-fullscreen https://angular-go-full-screen-f11-key.stackblitz.io
Why "Exit full screen" does not work when starting with full screen mode? How can I fix this?