QuachNguyen
QuachNguyen

Reputation: 131

How to show full screen popup with JavaScript?

I would like to show full screen popup with JavaScript? I use this code below but it isn't works on Firefox and Opera browser.

function detectVersion()
{
    version = parseInt(navigator.appVersion);
    return version;
}

function detectOS()
{
    if (navigator.userAgent.indexOf('Win') == -1) {
        OS = 'Macintosh';
    } else {
        OS = 'Windows';
    }
    return OS;
}

function detectBrowser()
{
    if (navigator.appName.indexOf('Netscape') == -1) {
        browser = 'IE';
    } else {
        browser = 'Netscape';
    }
    return browser;
}

function FullScreen(url){

    var adjWidth;
    var adjHeight;

    if ((detectOS() == 'Macintosh') && (detectBrowser() == 'Netscape')) {
        adjWidth = 20;
        adjHeight = 35;
    }
    if ((detectOS() == 'Macintosh') && (detectBrowser() == 'IE')) {
        adjWidth = 20;
        adjHeight = 35;
        winOptions = 'fullscreen=yes';
    }
    if ((detectOS() == 'Windows') && (detectBrowser() == 'Netscape')) {
        adjWidth = 30;
        adjHeight = 30;
    }
    if (detectVersion() < 4) {
        self.location.href = url;
    } else {
        var winWidth = screen.availWidth - adjWidth;
        var winHeight = screen.availHeight - adjHeight;
        var winSize = 'width=' + winWidth + ',height=' + winHeight;
        var thewindow = window.open(url, 'WindowName', winSize);
        thewindow.moveTo(0,0);
    }
}

function MakeItSo(url){
    if ((detectOS() == 'Windows') && (detectBrowser() == 'IE')) {
        window.open(url,'windowname','fullscreen=yes');
    } else {
        onload=FullScreen();
    }
}

I would appreciate help,

Nguyen

Upvotes: 1

Views: 2300

Answers (2)

Licson
Licson

Reputation: 2271

Have you checked the HTML5 fullscreen API?

document.body.requestFullscreen();

(Don't forget the vendor prefixs!)

If the browser don't support it you can try to use fullscreen popups as you do or just prompt your user to enter fullscreen mode themselves.

Upvotes: 0

Joshua
Joshua

Reputation: 1963

1) most modern browsers block popups, so your work will just be disabled.

2) opening a full screen popup blatantly invades the users environment. If it's an application that you want to run full screen, it would be better to include a note to educate your users about the F11 key (on windows Fx, IE)

Upvotes: 1

Related Questions