2
votes

I'm working on a application which works in full screen mode. I'm using a Iframe to go to fullscreen. the problem is how to close that fullscreen on button click?

I'm using this code:

function exitfs(){
    if (document.cancelFullScreen) {
        document.cancelFullScreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if (document.webkitCancelFullScreen) {
        document.webkitCancelFullScreen();
    }
} 

It works fine if i run it through firebug console but not works when bind with click event?

 function fullscreen(keys) {
    var f = e('newIfrane');
    if (keys) {
        if (f.mozRequestFullScreen) {
            f.mozRequestFullScreenWithKeys();
        } else if (f.webkitRequestFullScreen) {
            f.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
        }
    } else {
        if (f.mozRequestFullScreen) {
            f.mozRequestFullScreen();
        } else if (f.webkitRequestFullScreen) {
            f.webkitRequestFullScreen();
        }
    }
}

calling this function like fullscreen(false);

Note: Iframe is loading the same page in fullscreen mode. In Page there is a Image on click of that image I'm calling exitfs().

I'm not getting what is the problem? Thanks...

2
Is it called "newIfrane" on purpose? - Tasos Bitsios
You first show some code that works, in Firebug. Then say that it doesn't work on a click event and then shows us a function, that does not contain the code that worked nor any click event. Please update the question. - Henrik Ammer
the code given above cancelFullScreen... is the code which works fine if executed using firebug console (ie. exiting from fullscreen) - Ravi
@Tasos newIfrane is the id of iframe which loads my page in fullscreen - Ravi
How exactly are you trying exitfs() in console? You're probably calling it under the context of top window instead of iframe. - Passerby

2 Answers

2
votes

as suggested by Passerby I tried with the parent.exitfs(); and it worked for me. hope it will help someOne...

0
votes
 class Clickfullpage implements ClickHandler
 {
  public void onClick(ClickEvent event)
  {
    hello1(counter);
  }
}

public static native void hello1(int counter)
/*-{
 var body=$doc.getElementsByTagName("body")[0];
 var id=$doc.getElementById("vp");
 cancelFullscreen();
 function cancelFullscreen() 
   { 
      if ($doc.mozcancelFullScreen) 
      {
         $doc.mozcancelFullScreen();
      } 
     else
     if ($doc.webkitcancelFullScreen) 
      {
        $doc.webkitcancelFullScreen();
      }
   }   
}-*/;