X
Tap here to go to the mobile version of the site.

Support Forum

mozCancelFullScreen() not working and firefox not exiting fullscreen even though this function was called on document

Posted

I have a container which gets into full screen mode using mozRequestFullScreen() API but I want to get back to non-fullscreen mode after one of my custom event is fired.

As soon as my custom event is fired, I call mozCancelFullScreen() API to exit full screen but this seems to be not working. Firefox is not exiting fullscreen even though this function was called on document.

I have to press "Esc" to get into non-fullscreen mode.

I am uding Firefox 21.0 version.

I have a container which gets into full screen mode using mozRequestFullScreen() API but I want to get back to non-fullscreen mode after one of my custom event is fired. As soon as my custom event is fired, I call mozCancelFullScreen() API to exit full screen but this seems to be not working. Firefox is not exiting fullscreen even though this function was called on document. I have to press "Esc" to get into non-fullscreen mode. I am uding Firefox 21.0 version.

Additional System Details

Application

  • User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36

More Information

cor-el
  • Top 10 Contributor
  • Moderator
12919 solutions 118469 answers
See: *http://blog.pearce.org.nz/2011/11/firefoxs-html-full-screen-api-enabled.html *https://developer.mozilla.org/en-US/docs/Web/API/document.mozCancelFullScreen

Modified by cor-el

Question owner

Thanks for the reply. I am using the same API as mentioned in the urls. But the issue is something different here.

"As soon as my custom event is fired, I call mozCancelFullScreen() API to exit full screen but this seems to be not working. Firefox is not exiting fullscreen even though this function was called on document."

Also, pressing "Esc" to exit fullscreen in Firefox is inconsistent. I have to interact with flash plugin (my video player) like click or something and after than if I press "Esc" key, I am able to exit fullscreen.

Appreciate your help. Thanks.

Thanks for the reply. I am using the same API as mentioned in the urls. But the issue is something different here. "As soon as my custom event is fired, I call mozCancelFullScreen() API to exit full screen but this seems to be not working. Firefox is not exiting fullscreen even though this function was called on document." Also, pressing "Esc" to exit fullscreen in Firefox is inconsistent. I have to interact with flash plugin (my video player) like click or something and after than if I press "Esc" key, I am able to exit fullscreen. Appreciate your help. Thanks.
jscher2000
  • Top 10 Contributor
3774 solutions 33423 answers

There is a demo here showing that a user-initiate keyboard event can trigger both the request and the cancel: https://developer.mozilla.org/samples/domref/fullscreen.html

Could the problem be that you are not responding to a user-initiated event??

There is a demo here showing that a user-initiate keyboard event can trigger both the request and the cancel: https://developer.mozilla.org/samples/domref/fullscreen.html Could the problem be that you are not responding to a user-initiated event??
Sinisa Spasojevic 0 solutions 3 answers

I have the same problem. User-initiated event is mouse click, not key press, I wonder if that is the problem?

In Mozilla's demo, key event is used, not mouse event. Is mouse event also supported?

I am 100% sure that within callback function onclick I am calling document.mozCancelFullScreen() but nothing happens. Alert box that I placed in the same function, after mozCancelFullScreen() call is triggered. There's no error report in Firebug.

If there would be a working demo that uses onclick event to switch from fullscreen to normal, that would be highly appreciated!


p.s.

In Mozilla's demo, key event listener is added to document, while my onclick event to a div element. Maybe that's the problem?

I have the same problem. User-initiated event is mouse click, not key press, I wonder if that is the problem? In Mozilla's demo, key event is used, not mouse event. Is mouse event also supported? I am 100% sure that within callback function onclick I am calling document.mozCancelFullScreen() but nothing happens. Alert box that I placed in the same function, after mozCancelFullScreen() call is triggered. There's no error report in Firebug. If there would be a working demo that uses onclick event to switch from fullscreen to normal, that would be highly appreciated! p.s. In Mozilla's demo, key event listener is added to document, while my onclick event to a div element. Maybe that's the problem?

Modified by Sinisa Spasojevic

jscher2000
  • Top 10 Contributor
3774 solutions 33423 answers

Helpful Reply

Hi visionmax, could you post a link to your page, or create a demo on http://jsfiddle.net/ ?

Hi visionmax, could you post a link to your page, or create a demo on http://jsfiddle.net/ ?
Sinisa Spasojevic 0 solutions 3 answers

Hi jscher2000,

Here's the code: http://jsfiddle.net/ahMST/

I've actually realized, while copy-pasting code from my project (I couldn't use it as-is since there were a lot of dependencies and prototyping) that there was a typo in my code, instead of mozCancelFullScreen I had mozCancelFullscreen.

Though the code does not work on jsfiddle.net, it does work on host: http://www.visionmax.hk/tmp/fstest/

Thanks!

Hi jscher2000, Here's the code: http://jsfiddle.net/ahMST/ I've actually realized, while copy-pasting code from my project (I couldn't use it as-is since there were a lot of dependencies and prototyping) that there was a typo in my code, instead of mozCancelFullScreen I had mozCancelFullscreen. Though the code does not work on jsfiddle.net, it does work on host: http://www.visionmax.hk/tmp/fstest/ Thanks!
jscher2000
  • Top 10 Contributor
3774 solutions 33423 answers

Hi visionmax, on your site, I have to approve the full screen before I can click, but then it does close. So it's solved?

Hi visionmax, on your site, I have to approve the full screen before I can click, but then it does close. So it's solved?
Sinisa Spasojevic 0 solutions 3 answers

Hi jscher2000,

Yes it is solved: ".... that there was a typo in my code, instead of mozCancelFullScreen I had mozCancelFullscreen."

-) typo error, and since I had checked "if( document.mozCancelFullscreen )", and which was always null, no errors were reported in Firebug.
Hi jscher2000, Yes it is solved: ".... that there was a typo in my code, instead of mozCancelFullScreen I had mozCancelFullscreen." :-) typo error, and since I had checked "if( document.mozCancelFullscreen )", and which was always null, no errors were reported in Firebug.