2

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...

Ravikumar Sharma
  • 3,678
  • 5
  • 36
  • 59

2 Answers2

2

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

Ravikumar Sharma
  • 3,678
  • 5
  • 36
  • 59
  • hi ravi, I am doing the same thing but finding some problem can you please help me I am using the following code in jsni.. public static native void hello1(int counter) /*-{ var body=$doc.getElementsByTagName("body")[0]; var id=$doc.getElementById("vp"); cancelFullscreen(id); function cancelFullscreen(id) { if (id.mozcancelFullScreen) { id.mozcancelFullScreen(); } else if (id.webkitcancelFullScreen) { id.webkitcancelFullScreen(); } } }-*/; –  Jul 28 '14 at 11:03
  • where counter is 1 initially and the id is for particular html id this function is not working –  Jul 28 '14 at 11:06
  • what is the parent that you are taking about –  Jul 28 '14 at 11:07
  • parent of iframe (ie window.parent) – Ravikumar Sharma Jul 28 '14 at 11:49
  • i have posted as an answer please check it once –  Jul 28 '14 at 11:53
0
 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();
      }
   }   
}-*/;