问题
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...
回答1:
as suggested by Passerby I tried with the parent.exitfs(); and it worked for me. hope it will help someOne...
回答2:
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();
}
}
}-*/;
来源:https://stackoverflow.com/questions/12400912/exit-from-full-screen-not-working