Fullscreen using HTML5 and JavaScript

I have tried to fullscreen a div using JavaScript. Here is my HTML and JS:

    var elem = document.getElementById('fullscreenThis');
    function openFullscreen() {
    if (elem.requestFullscreen) {
        elem.requestFullscreen();
    } else if (elem.mozRequestFullScreen) {
        elem.mozRequestFullScreen();
    } else if (elem.webkitRequestFullscreen) {
        elem.webkitRequestFullscreen();
    } else if (elem.msRequestFullscreen) {
        elem.msRequestFullscreen();
    }
    }
    document.getElementById('fullscreen').addEventListener('click', openFullscreen);
<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <body>
    <div id="fullscreenThis">
        Here is some code I want to fullscreen
    </div>
    <button id="fullscreen">fullscreen</button>
    <script src="main.js"></script>
    </body>
    </html>

I have tried this in Firefox and Chrome.

230 thoughts on “Fullscreen using HTML5 and JavaScript”

  1. It is appropriate time to make some plans for the future and it is time to be
    happy. I have read this post and if I could I
    desire to suggest you few interesting things or advice.

    Maybe you can write next articles referring to this article.
    I wish to read even more things about it!

    Reply
  2. I’ll right away take hold of your rss feed as I can not in finding your e-mail
    subscription link or e-newsletter service. Do you’ve any?

    Please allow me understand in order that I may just subscribe.
    Thanks.

    Reply
  3. I know this if off topic but I’m looking into starting my
    own blog and was curious what all is required to get set up?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very internet savvy so I’m not 100% positive.
    Any suggestions or advice would be greatly appreciated.
    Kudos

    Reply
  4. Hello just wanted to give you a quick heads up.
    The text in your content seem to be running off the screen in Safari.

    I’m not sure if this is a format issue or something to do with web browser compatibility but I figured I’d post to let you
    know. The design and style look great though!
    Hope you get the issue fixed soon. Thanks

    Reply
  5. It is perfect time to make a few plans for the future and it’s time to be happy.
    I have read this put up and if I may I want to suggest you few interesting things
    or advice. Perhaps you could write subsequent articles referring
    to this article. I wish to read more things approximately it!

    Reply
  6. Woah! I’m really loving the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s challenging to get that
    “perfect balance” between user friendliness and appearance.
    I must say you have done a fantastic job with this.
    In addition, the blog loads super quick for me on Opera.
    Superb Blog!

    Reply
  7. I’ve been browsing online more than 2 hours today, yet I never found any interesting
    article like yours. It’s pretty worth enough for me.
    In my opinion, if all webmasters and bloggers made good content as
    you did, the web will be much more useful than ever before.

    Reply
  8. I’ll immediately seize your rss as I can’t in finding your e-mail subscription hyperlink or newsletter service.
    Do you’ve any? Please allow me know in order that I may just subscribe.
    Thanks.

    Reply
  9. Its such as you read my thoughts! You seem to understand so much approximately this, like
    you wrote the book in it or something. I think that you simply can do with
    a few p.c. to pressure the message house a little
    bit, however other than that, that is fantastic blog.
    An excellent read. I will definitely be back.

    Reply
  10. Hi, I do believe this is an excellent website. I stumbledupon it 😉 I
    may return once again since I book-marked it. Money
    and freedom is the best way to change, may you be rich and continue to guide other people.

    Reply
  11. Hi, I think your blog might be having browser compatibility issues.

    When I look at your blog site in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that, awesome blog!

    Reply
  12. Thanks for the various tips contributed on this blog site. I have noticed that many insurance carriers offer buyers generous reductions if they opt to insure multiple cars with them. A significant number of households own several autos these days, in particular those with more aged teenage young children still residing at home, as well as savings with policies can easily soon begin. So it is a good idea to look for a bargain.

    Reply
  13. Heya i am for the primary time here. I came across this board and I in finding It truly useful & it helped me out a lot. I am hoping to give something back and help others such as you aided me.

    Reply
  14. I’ve been browsing online more than 3 hours today, yet I never
    found any interesting article like yours.

    It is pretty worth enough for me. Personally, if all webmasters and bloggers made good content as you
    did, the net will be much more useful than ever before.

    Reply
  15. It’s appropriate time to make a few plans for the long run and it’s time to be happy.
    I have read this post and if I may I wish to suggest you some interesting issues or advice.
    Maybe you can write subsequent articles regarding this article.

    I wish to read even more things about it!

    Reply
  16. I have been surfing online more than three hours today, yet
    I never found any interesting article like yours. It is pretty worth enough
    for me. In my view, if all webmasters and bloggers made good content as you did, the web will be
    a lot more useful than ever before.

    Reply
  17. Pingback: cialis soft
  18. Pingback: cialis best price
  19. Pingback: buy cialis 5mg
  20. Pingback: viagra cheap
  21. Pingback: sildenafil 100mg
  22. I do not know whether it’s just me or if perhaps everybody else
    experiencing issues with your blog. It looks like some
    of the text on your content are running off the screen. Can somebody else
    please provide feedback and let me know if this is happening
    to them too? This might be a problem with my internet browser because I’ve had this happen previously.

    Cheers

    Reply
  23. Pingback: viagra sale au
  24. Pingback: viagracarme
  25. Pingback: cialis sex pill
  26. Pingback: zithramax effects
  27. Pingback: ventolin sulfate
  28. Pingback: sildenafil 50 mg
  29. Pingback: viagra bestellen
  30. Pingback: viagra prices
  31. Pingback: viagra jokes
  32. Pingback: viagra cialis
  33. Pingback: walmart viagra
  34. Pingback: doctor x viagra
  35. Pingback: hims viagra
  36. Pingback: lady viagra
  37. Pingback: cheap viagra
  38. Pingback: pfizer viagra
  39. Pingback: viagra for men
  40. Pingback: women viagra
  41. Pingback: cialis or viagra
  42. Can you be struck by more than one erection in a celibate session? Yes and no. You may be masterly to become establish more than decidedly, but you probable won’t be masterly to ejaculate, or put in an appearance, without experiencing a latency period. Reminisce over: Orgasm and ejaculation are very different things. Source: buy cialis no prescription

    Reply

Leave a Comment