Skip to main content
1-Visitor
December 14, 2018
Solved

How to enable/disable Full Screen(F11) mode by clicking a Button?

  • December 14, 2018
  • 5 replies
  • 5642 views

Hi There,

 

I was trying to enable full-screen mode by clicking a button instead of f11 option.

I used the following HTML code as a normal HTML file, works cool.

 

<button  onclick='document.documentElement.webkitRequestFullscreen();'>Go Fullscreen Mode</button><button onclick='document.webkitExitFullscreen();'>Close Fullscreen</button>

 

I also tried HtmlTextArea widget with the read-only option enabled, Not getting the expected result.

Even I tried WebFrame widget to call the HTML file and execute, not worked.

 

Give me a solution if exist.

 

Best answer by CarlesColl

Add an Expression widget and on the expression field set:

 

($("#runtime")[0].webkitRequestFullScreen()?$("#runtime")[0].webkitRequestFullScreen():($("#runtime")[0].mozRequestFullScreen()?$("#runtime")[0].mozRequestFullScreen():$("#runtime")[0].msRequestFullscreen()?$("#runtime")[0].msRequestFullscreen():$("#runtime")[0].requestFullScreen()))

Then when you want full screen you just need to trigger this expression (from a button Click event, should be started by a user clicking the button)

 

5 replies

1-Visitor
December 17, 2018

Add an Expression widget and on the expression field set:

 

($("#runtime")[0].webkitRequestFullScreen()?$("#runtime")[0].webkitRequestFullScreen():($("#runtime")[0].mozRequestFullScreen()?$("#runtime")[0].mozRequestFullScreen():$("#runtime")[0].msRequestFullscreen()?$("#runtime")[0].msRequestFullscreen():$("#runtime")[0].requestFullScreen()))

Then when you want full screen you just need to trigger this expression (from a button Click event, should be started by a user clicking the button)

 

1-Visitor
December 17, 2018

Hi,

 

Works for FullScreen!

 

I tried the following combinations two ExitFull Screen, Not Working..,

 

($("#runtime")[0].webkitExitFullscreen()?$("#runtime")[0].webkitExitFullscreen():($("#runtime")
[0].mozCancelFullScreen()?$("#runtime")[0].mozCancelFullScreen():$("#runtime")[0].msExitFullscreen()?$("#runtime")[0].msExitFullscreen():$("#runtime")[0].exitFullscreen()))

 

($("#runtime")[1].webkitExitFullscreen()?$("#runtime")[1].webkitExitFullscreen():($("#runtime")
[1].mozCancelFullScreen()?$("#runtime")[1].mozCancelFullScreen():$("#runtime")[1].msExitFullscreen()?$("#runtime")[1].msExitFullscreen():$("#runtime")[1].exitFullscreen()))

 

How I exit the FullScreen?

1-Visitor
December 17, 2018

You can't control exiting full screen from within the page, should be the user with "ESC" keyboard key.