How can I open the chrome in F11 mode by navigation to another page in Angular Application?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How can I open the chrome in F11 mode by navigation to another page in Angular Application?



I am developing an application where i need user when user logs in screen should be full (Example like : Chrome f11) & after logout return to its original postilion.





Possible duplicate of How to make the window full screen with Javascript (stretching all over the screen)
– CodeCaster
Aug 10 at 9:56





Its not duplicate buddy i need this in Angular
– Jignesh Mistry
Aug 10 at 9:57





You can call JavaScript code from Angular, pal.
– CodeCaster
Aug 10 at 9:59





Can u please show it here - stackblitz.com/edit/angular-jfr7zf
– Jignesh Mistry
Aug 10 at 10:00




2 Answers
2



If you dont want to add an extra library dependency, you can just implement a full-screen toggle function like this:


/**
* Toggles the fullscreen mode.
*/
toggleFullscreen()
if (document.webkitIsFullScreen)
this._exitFullscreen();
else
this._activateFullscreen();



/**
* Activate Full Screen Mode.
*/
private _activateFullscreen()
let fullscreenElement = document.documentElement;
if (fullscreenElement.requestFullscreen)
fullscreenElement.requestFullscreen();
else if (fullscreenElement.mozRequestFullScreen)
/* Firefox */
fullscreenElement.mozRequestFullScreen();
else if (fullscreenElement.webkitRequestFullscreen)
/* Chrome, Safari and Opera */
fullscreenElement.webkitRequestFullscreen();
else if (fullscreenElement.msRequestFullscreen)
/* IE/Edge */
fullscreenElement.msRequestFullscreen();



/**
* Exits Full Screen Mode.
*/
private _exitFullscreen()
if (document.exitFullscreen)
document.exitFullscreen();
else if (document.mozCancelFullScreen)
/* Firefox */
document.mozCancelFullScreen();
else if (document.webkitExitFullscreen)
/* Chrome, Safari and Opera */
document.webkitExitFullscreen();
else if (document.msExitFullscreen)
/* IE/Edge */
document.msExitFullscreen();




Link to example Code & Demo.



Take a look at this library:
https://github.com/sindresorhus/screenfull.js/



There's an Angular 2 Example too:


import Directive, HostListener from '@angular/core';
import * as screenfull from 'screenfull';

@Directive(
selector: '[toggleFullscreen]'
)
export class ToggleFullscreenDirective

@HostListener('click') onClick()
if (screenfull.enabled)
screenfull.toggle();





And then in your markup:


<button toggleFullscreen>Toggle fullscreen<button>



Then you can act based on your events and request fullscreen, toggle it on or off based on your needs.





OK let me try it
– Jignesh Mistry
Aug 10 at 10:00





Thanks :) Now i need to implement when user navigates from one page to other
– Jignesh Mistry
Aug 10 at 10:07





Handle that in your components handling the navigation or the component that loads on the specific pages. You can query whether the user is in fullscreen mode or not and act accordingly. If you need more help, just give me a heads up and include your code.
– Agash Thamo.
Aug 10 at 10:19





Sure buddy :) I will revert if needed
– Jignesh Mistry
Aug 10 at 10:20






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard