1

I'm developping a website in VB.Net by VS2013.
In webform View_SXCT.aspx (webform using masterpage), I have a javascript :

<script language="JavaScript">
    function fullScreen() {
        var el = document.documentElement
            , rfs = // for newer Webkit and Firefox
                   el.requestFullScreen
                || el.webkitRequestFullScreen
                || el.mozRequestFullScreen
                || el.msRequestFullScreen
        ;
        if (typeof rfs != "undefined" && rfs) {
            rfs.call(el);
        } else if (typeof window.ActiveXObject != "undefined") {
            // for Internet Explorer
            var wscript = new ActiveXObject("WScript.Shell");
            if (wscript != null) {
                wscript.SendKeys("{F11}");
            }
        }

    }
    // End -->
</script>

With a button. Everything is easy by <a href="javascript:void(0);" onclick="fullScreen();"><BUTTON></a>
But How can I load that script on pageload. That's mean that webform will be fullscreen on pageload without any click on anything.
Thanks.

  • if you can use jQuery you can use the `$(document).ready()` function – Pindo Jul 30 '15 at 02:34
  • I'm an amateur so can you explain? Thank – Duy Hưng Androgyne Tenor Jul 30 '15 at 04:07
  • Have a look at these links, they may help you: http://stackoverflow.com/questions/13303151/getting-fullscreen-mode-to-my-browser-using-jquery https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode – Pindo Jul 30 '15 at 05:21
  • Thanks. I read that thread but that case is only fullscreen on user action (e.g a click), not on pageload (without any user action). That's my problem :(. It's so easy to fullscreen on click a button in my case. – Duy Hưng Androgyne Tenor Jul 30 '15 at 06:58

1 Answers1

0

You have quite a few options for calling functions on page load.

If you are using jQuery the syntax is:

$(document).ready(fullScreen)

Without jQuery you can accomplish this with:

document.addEventListener("DOMContentLoaded", fullScreen);

But honestly the best way to call something on page load is to call the function with a script at the end of the HTML document. For more info this is a good post on the subject

<html>
    <head>
    ...
    </head>
    <body>
    ...
    <scripts go here/>
    </body>
</html>
Community
  • 1
  • 1
Burdock
  • 1,085
  • 1
  • 9
  • 22