开发者

How to force the browser to maximize (like pressing F11) from an NPAPI plugin?

I have a scriptable NPAPI browser plugin.

I would like to expose a method to javascript "MaximizeBrowser",

that will cause the browser window to maximize (as if the user pressed F11 in the broswer).

Is there a way to achieve that?

开发者_JAVA技巧

The selected answer works (at least on Windows)!

Here is my code, in case someone needs:

// simulate F11 keyboard key press
keybd_event(VK_F11,MapVirtualKey(VK_F11,0),0,0); 
keybd_event(VK_F11,MapVirtualKey(VK_F11,0),KEYEVENTF_KEYUP,0); 


There's certainly no supported way using the NPAPI APIs, but depending on what OS you are targeting you could try using OS-level calls to simulate a keyboard event matching the browser's full-screen mode. That will of course be fragile since it depends on every browser you are targeting a) having a full screen mode, and b) never changing the shortcut.

If your goal is to have your plugin content be full-screen, perhaps you should instead consider opening a full-screen window from your plugin, which is how other NPAPI plugins go full-screen.


There is no way to maximize the browser window to full screen with JavaScript. While this is unfortunate for your genuine requirement, it is considered a security restriction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜