简体   繁体   English

Javascript:自动最大化浏览器窗口并切换到全屏模式?

[英]Javascript: Automatically maximize browser window and switch to full screen mode?

I am working on a Flash app that is 900x700 pixels. 我正在开发一个900x700像素的Flash应用。 When viewed in misc. 在misc中查看时。 browsers at 1024x768, the browser chrome causes robs too much of the vertical space and the app appears in a window with a vertical scrollbar. 在1024x768的浏览器中,浏览器镶边会导致占用过多的垂直空间,应用程序会出现在带有垂直滚动条的窗口中。 Unacceptable. 不能接受的。

The flash app will be launched via a link emailed to the viewers. Flash应用程序将通过电子邮件发送给观众的链接启动。

I'd like to avoid resizing the flash app and am wondering if there's a way to do the following via javascript, with no clicks involved: 我想避免调整Flash应用程序的大小,我想知道是否有办法通过javascript执行以下操作,不涉及任何点击:

  1. maximize the current browser window 最大化当前浏览器窗口
  2. remove current window address bar and tabs / switch browser to full screen view (equivalent to pressing F11). 删除当前窗口地址栏和选项卡/将浏览器切换到全屏视图(相当于按F11)。

An alternative would be to resize the flash app vertically to match the browser canvas height to avoid scrolling. 另一种方法是垂直调整Flash应用程序的大小以匹配浏览器画布高度以避免滚动。 This may cause the app to become unreadable, so not the best approach in my case. 这可能会导致应用程序变得不可读,因此在我的情况下不是最好的方法。

Thank you! 谢谢!

UPDATE: Seems that browser resizing and autoswitch to full screen won't work and neither will the flash app auto resize. 更新:似乎浏览器调整大小和自动切换到全屏将无法正常工作,Flash应用程序也不会自动调整大小。 What is the best approach then? 那么最好的方法是什么? And, some users may have browsers with toolbars or open a small browser window. 并且,一些用户可能拥有带工具栏的浏览器或打开一个小浏览器窗口。

The only idea I have is to use javascript and display a message to users with small browser windows to pres F11 manually. 我唯一的想法是使用javascript并向具有小浏览器窗口的用户显示消息以手动压缩F11。 The audience is executes and some may not even know what an F11 means... 观众是执行的,有些甚至可能不知道F1​​1意味着什么......

There is no way to maximize the browser window to full screen with JavaScript. 使用JavaScript无法将浏览器窗口最大化为全屏。 While this is unfortunate for your genuine requirement, it is considered a security restriction. 虽然这对您的真实要求是不幸的,但它被视为安全限制。

Sources: 资料来源:

The window size can be altered by using: 可以使用以下方法更改窗口大小:

window.moveTo(0, 0);
window.resizeTo(screen.availWidth, screen.availHeight);

You can use JavaScript to open a new window (using window.open ) and control the window that is opened (no address bar, etc). 您可以使用JavaScript打开一个新窗口(使用window.open )并控制打开的窗口(没有地址栏等)。 You can also control the size of the window (you can't maximize it, but you can get the users screen size, and set the window that same size). 您还可以控制窗口的大小(您无法最大化它,但您可以获取用户屏幕大小,并设置相同大小的窗口)。

To answer the question in the comment you made to your own post. 要回答您对自己帖子的评论中的问题。 Yes. 是。 You can have a button whose click handler does this 你可以有一个按钮,其点击处理程序执行此操作

stage.displayState = StageDisplayState.FULL_SCREEN;

Chrome 15, Firefox 10, and Safari 5.1 now provide APIs to programmatically trigger fullscreen mode. Chrome 15,Firefox 10和Safari 5.1现在提供API以编程方式触发全屏模式。 Fullscreen mode triggered this way provide events to detect fullscreen changes and CSS pseudo-classes for styling fullscreen elements. 以这种方式触发的全屏模式提供检测全屏变化的事件和用于样式化全屏元素的CSS伪类。 These APIs may present you with a more acceptable solution for those browsers. 这些API可能会为您提供更适合这些浏览器的解决方案。

See this hacks.mozilla.org blog post for details. 有关详细信息,请参阅hacks.mozilla.org博客文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在浏览器中使用Javascript响应切换到全屏模式(又称“剧院模式”) - Responding to a switch to full-screen mode (AKA “theater mode”) in the browser, with Javascript 相对于浏览器窗口的JavaScript全屏显示,不监视 - JavaScript full screen relative to browser window, not monitor 在正常模式和全屏模式之间切换窗口 - Switch window between normal and full-screen mode 如何将新的浏览器实例设置为全屏模式,而不是量角器最大化 - How do i set a new browser instance in to a full screen mode, not as maximize in protractor 具有javascript(跨浏览器)或其他功能的全屏浏览器窗口? - Full screen browser window with javascript (cross-browser) or alternatives? 检测浏览器是否处于全屏模式 - Detecting if a browser is in full screen mode 我想在最大化模式下单击按钮在浏览器中打开新窗口 - I want to open the new window in browser on the click of button in maximize mode 具有屏幕尺寸模式的JavaScript的Window.Open()方法仍以最小化模式打开浏览器窗口 - JavaScript's Window.Open() method with screen size mode is still opening browser window in minimized mode Cypress:检查浏览器是否处于全屏模式 - Cypress: check if browser is in full screen mode 加载文档上的全屏浏览器窗口 - full-screen browser window on load document
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM