本文介绍了如何用Javascript打开最大化窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Javascript的 self.open()在新窗口中打开一个链接,我希望该窗口最大化。我尝试了 fullscreen = yes 选项,这实际上并没有达到我想要的效果。我使用下面的代码:

I'm using Javascript's self.open() to open a link in a new window and i'd like that window to be maximized. I tried the fullscreen=yes option, which really doesn't do what I want. I am using below code:

self.open(pageLoc,popUpName,'height=1600,width=1800,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes');

如果我还提到 fullscreen = yes ,然后窗口打开就像你按F11。但我不希望如此。我想要的是当我双击 IE 并点击右上角的最大化图标时。

If i also mention fullscreen=yes, then window opens up like you press F11. But i don't want it that. What i want is when i double click on IE and click maximize icon on top right corner.

因为我给了 height width 值如此之大,它接近最大化窗口但不是实际最大化窗口。 (我说这个的原因是因为
即使现在如果我点击最大化按钮,它会进一步扩展一点点)

As i have given the height and width value so large, it is close to maximized window but not actual maximized window. (the reason i am saying this because even now if i click maximize button, it further expans little bit)

推荐答案

var params = [
    'height='+screen.height,
    'width='+screen.width,
    'fullscreen=yes' // only works in IE, but here for completeness
].join(',');
     // and any other options from
     // https://developer.mozilla.org/en/DOM/window.open

var popup = window.open('http://www.google.com', 'popup_window', params);
popup.moveTo(0,0);

除非用户真的需要,否则请不要打开弹出窗口,否则他们会诅咒你并将你列入黑名单现场。 ; - )

Please refrain from opening the popup unless the user really wants it, otherwise they will curse you and blacklist your site. ;-)

编辑:哎呀,正如Joren Van Severen在评论中指出的那样,这可能不会考虑任务栏和窗口装饰(以可能的浏览器依赖方式)。意识到。似乎忽略高度和宽度(只有param是 fullscreen = yes )似乎也适用于Chrome和Firefox; Firefox中禁用了原始的全屏功能,因为它是令人讨厌的,但已经被最大化所取代。这与表示窗口最大化是不可能的。根据浏览器的不同,可能支持也可能不支持此功能。

edit: Oops, as Joren Van Severen points out in a comment, this may not take into account taskbars and window decorations (in a possibly browser-dependent way). Be aware. It seems that ignoring height and width (only param is fullscreen=yes) seems to work on Chrome and perhaps Firefox too; the original 'fullscreen' functionality has been disabled in Firefox for being obnoxious, but has been replaced with maximization. This directly contradicts information on the same page of https://developer.mozilla.org/en/DOM/window.open which says that window-maximizing is impossible. This 'feature' may or may not be supported depending on the browser.

这篇关于如何用Javascript打开最大化窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 17:34