最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Programmatically put Google Chrome into full-screen mode with Javascript? - Stack Overflow

programmeradmin0浏览0评论

I was on youtube recently when I clicked the fullscreen button by the youtube video and a message appeared at the top of the screen saying that I was put into full-screen mode. This message was the native message you get when pressing f-11 on your keyboard. I also read something somewhere(that I now cannot find) saying that it's now possible to do this with Javascript.

Question

How would I put the users browser(Google Chrome) into fullscreen, on command? - without an extension they would need to download prior, or anything of that nature.

I'm using jQuery so that would be best, but I can't find how to do it at all.

EDIT: I've seen other questions of this nature, but they were asked a long time ago, and I believe this functionality is fairly new.

I was on youtube recently when I clicked the fullscreen button by the youtube video and a message appeared at the top of the screen saying that I was put into full-screen mode. This message was the native message you get when pressing f-11 on your keyboard. I also read something somewhere(that I now cannot find) saying that it's now possible to do this with Javascript.

Question

How would I put the users browser(Google Chrome) into fullscreen, on command? - without an extension they would need to download prior, or anything of that nature.

I'm using jQuery so that would be best, but I can't find how to do it at all.

EDIT: I've seen other questions of this nature, but they were asked a long time ago, and I believe this functionality is fairly new.

Share Improve this question edited Nov 4, 2011 at 21:41 Kirk Woll 77.6k23 gold badges186 silver badges197 bronze badges asked Nov 4, 2011 at 21:36 android.nickandroid.nick 11.2k24 gold badges78 silver badges112 bronze badges 6
  • Do you have a link to the YouTube video that does this? Are you sure it wasn't Flash? – Jared Farrish Commented Nov 4, 2011 at 21:37
  • Isn't this the fullscreen mode from flash? – yunzen Commented Nov 4, 2011 at 21:37
  • possible duplicate of Is there a way to make HTML5 video fullscreen? – Kirk Woll Commented Nov 4, 2011 at 21:38
  • 1 This question doesn't have enough jQuery in it. – scottheckel Commented Nov 4, 2011 at 21:39
  • I get different message with fullscreen from youtube than I get from pressing F11 – yunzen Commented Nov 4, 2011 at 21:39
 |  Show 1 more comment

3 Answers 3

Reset to default 11

Here is good article: Native Fullscreen JavaScript API . It describes all three methods: webkit, firefox and W3-proposal.

// mozilla proposal
element.requestFullScreen();
document.cancelFullScreen(); 

// Webkit (works in Safari and Chrome Canary)
element.webkitRequestFullScreen(); 
document.webkitCancelFullScreen(); 

// Firefox (works in nightly)
element.mozRequestFullScreen();
document.mozCancelFullScreen(); 

// W3C Proposal
element.requestFullscreen();
document.exitFullscreen();

Try these functions, they appear to be native:

void webkitRequestFullScreen();
void webkitRequestFullScreenWithKeys();
void webkitCancelFullScreen(); // only on Document

The API is still heavily in flux especially since the W3C joined in this week. I spent some time working through the differences to implement Full Screen in MediaElement.js HTML5 video player, and its working great in Safari 5.1+, Chrome 15+, or Firefox Nightly.

发布评论

评论列表(0)

  1. 暂无评论