2

Following is the script

 <script type="text/javascript">
            function DoFullScreen() {

                var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) ||    // alternative standard method  
                (document.mozFullScreen || document.webkitIsFullScreen);

                var docElm = document.documentElement;
                if (!isInFullScreen) {

                    if (docElm.requestFullscreen) {
                        docElm.requestFullscreen();
                    }
                    else if (docElm.mozRequestFullScreen) {
                        docElm.mozRequestFullScreen();
                        //alert("Mozilla entering fullscreen!");
                    }
                    else if (docElm.webkitRequestFullScreen) {
                        docElm.webkitRequestFullScreen();
                        alert("Webkit entering fullscreen!");
                    }
                }
            }

        </script>

HTML

<body onload="DoFullScreen()">
    <form id="form1" runat="server" >
        <div id="div1">
            <input id="bt1" type="button" value="button"   />
            Hello
        </div>
    </form>
</body>

I have tried

  1. $(window).load
  2. $(document).ready(function(){ $("#bt1").load
kumar
  • 1,796
  • 2
  • 15
  • 37
Somnath Kharat
  • 3,570
  • 2
  • 27
  • 51

3 Answers3

3

-- it's not possible force a fullscreen if it's not triggered by a user action

-- look at this

full-screen browser window on load document

Community
  • 1
  • 1
Ahmed Alnahas
  • 263
  • 1
  • 4
  • No, why should there be? Browsers do have popup blockers today because users where bothered by stupid website authors (and advertisers) too much – and you are trying to do the same thing, take control over something that is and should be under the user’s control. – CBroe May 07 '13 at 10:06
0

on ready call your function

$(document).ready(function(){

DoFullScreen();

}

Community
  • 1
  • 1
mastermind
  • 1,057
  • 1
  • 8
  • 15
  • 1
    Yes the trouble is you are calling the function DoFullScreen before that piece of html has even been parsed and loaded into the DOM! The jQuery "ready" shown in Mastermind's answer waits until everything has been loaded in before executing your code. – Shawson May 07 '13 at 09:46
0

You can do it using pure javascript only like this:

<script type="text/javascript">
window.onload = function () {

                // YOUR CODE STUFF 

                }
</script>
Subedi Kishor
  • 5,906
  • 5
  • 35
  • 53