window.fullScreen=true is not working

2019-02-25 04:07发布

I would like to open my html page in fullscreen mode. I tried to execute this javascript in body's onload event handler.

window.fullScreen = true;

But unfortunately that doesn't seem to be working. Is there any other way with which we can achieve the same.

6条回答
2楼-- · 2019-02-25 04:47

This is unadvisable as it results in unexpected browser behviour for the user. For this reason, many browsers no longer let unprivileged scripts modify this setting.

For example, from Mozilla Developer Center

With chrome privileges, the property is read-write, otherwise it is read-only.

See https://developer.mozilla.org/En/DOM/Window.fullScreen

查看更多
Rolldiameter
3楼-- · 2019-02-25 04:49
window.open(href, windowname, ',type=fullWindow,fullscreen,scrollbars=yes');

take it from link : http://www.htmlcodetutorial.com/linking/linking_famsupp_87.html

查看更多
forever°为你锁心
4楼-- · 2019-02-25 05:01

Try this script

<script language="JavaScript">
function fullScreen(theURL) {
window.open(theURL, '', 'fullscreen=yes, scrollbars=auto' );
}
</script>

For calling form script use

window.fullScreen('fullscreen.jsp');

or with hyperlink

<a href="javascript:void(0);" onclick="fullScreen('fullscreen.jsp');"> 
Open in Full Screen Window</a>
查看更多
Ridiculous、
5楼-- · 2019-02-25 05:04

Chrome 15, Firefox 10, and Safari 5.1 now provide APIs to programmatically trigger fullscreen mode.

See this hacks.mozilla.org blog post for details.

查看更多
唯我独甜
6楼-- · 2019-02-25 05:12

I dont think you can set the windows properties by using the onload event. Try setting the properties as you open the window. This should work...

<div onclick="window.open('http://stackoverflow.com', 'Stackoverflow' , 'type=fullWindow, fullscreen, scrollbars=yes');">
    Hello Stackoverflow!
</div>
查看更多
等我变得足够好
7楼-- · 2019-02-25 05:12

I'm pretty sure that most browsers block this nowadays as it's annoying.

查看更多
登录 后发表回答