I'm new to JavaScripts,so probably I did something wrong. I would like to use the window.open method to open a new non resizable window with a predefined size, and no scrollbar. In my HTML5 file I used the following lines:
Credits
The window displays correctly, the size is ok, but it is resizable and there is a scrollbar. I used Chrome as default browser.
scrollbars=yes|no|1|0 Whether or not to display scroll bars. IE, Firefox & Opera only
Source: http://www.w3schools.com/jsref/met_win_open.asp
Check this SO answer:
window.open not resizable, scrollable
The values for resizable are 0, 1 , "no" and "yes", but resizable is IE only
Each user can configure their browser so that it opens a new tab instead of a new window.
Related
I'm trying to figure out how I could use window.open to open a window in Chrome without having this window displayed on top of the active window.
I'm using this:
_Top.window.open(myURL,myWindowID,'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,alwaysLowered=yes,z-lock="yes",resizable=1,top=800,left='+pxLeft+',width='+myWidth+',height='+myHeight);
I'm trying with alwaysLowered, z-lock, ... but when used on Chrome, the new windows comes on top of the active window. It works in Firefox and IE but not on Chrome.
I also use:
_Top.window.blur();
Is there a parameter to achieve this or should I use something else for Chrome?
Thanks
Laurent
I'm looking for a way to resize the Chrome browser's width with a button. Preferentially using JQuery. My goal is to show the mobile version of the website to desktop users.
I know I can do this by just resizing the BODY tag (which is definitely easier) but I got curious.
I haven't found reliable answers to this question and sorry if it has already been asked.
Other ideas are always welcome.
Thanks. :)
Recent browsers (since FF7) aren't going to support window.resizeTo(x,y) unless it's a window you created that doesn't have any other tabs. This is to prevent abusive website code.
Check the notes on this MDN Window.resizeTo() help:
Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser, according to the following rules:
You can't resize a window or tab that wasn’t created by window.open.
You can't resize a window or tab when it’s in a window with more than one tab.
Like you mentioned, you can launch a new window with a specified size to preview a mobile experience. Alternatively, you could create an IFrame with a specified size:
<iframe src="/mobile" width="200" height="200">
As Pranspach mentioned you can't resize the actual chrome window, but if your site is responsive on resize you could wrap the whole site in a wrapper div and shrink that instead of body.
I have a simple JS script including:
OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
FF 21.0 opens it to the full size of the browser window.
Chrome and Opera correctly open it to the specified width and height.
Is this a known bug in FF? Is there some way around it?
You need to remove the space between height and width in your third argument.
See strWindowFeatures # MDN
Update:
As Pointy says, this doesn't seem to be the case (and from some testing it certainly doesn't affect me in FF 24). However, quoting from Firefox's tab preferences and settings page:
If you have chosen to open pages in new tabs, Firefox will ignore this option and will open a new window from a link if the page author specified that the new window should have a specific size, because some pages can only be displayed correctly at a specific size.
So this must have been changed from FF 21 til now. How are you triggering the window.open? I know some browsers differentiate based on event source, meaning you get different results on triggering it in Javascript vs. from a user-initiated event.
Voila! Pointy had the answer.
I hadn't noticed that the window was opening in a new tab.
I unchecked the browser open-in-a-new-tab option, and now I get the properly-sized window.
Thank You!
I have a JavaScript to re-size all my popup windows:
function resize()
{
window.resizeTo(240,230);
}
But now it is not resizing in Mozilla Firefox, but it was doing earlier, also
or if the popup window is opened in a new tab, it is not resizing, also in some browsers it is not also. Is there any piece of JavaScript code which works in all scenarios and all browsers?
Firefox comes with a preference for user to allow/disallow resizing of
window using Javascript. It's in Tools - Options - Content - Enable
Javascript -> [Advanced].
I am not sure if resizing is disabled by default, but you might want
to check your own Firefox installation first.
If it's disabled by default, then unfortunately there is nothing you
could do to resize the window after it has been opened. An ugly
workaround would be to open itself once again using window.open() with
the preferred size though.
Source: timdream (here)
I'll also add that:
You can't be assured that any browser will let you control the size of
windows you create. You can't even be sure you'll get a window at all
- people can instruct their browsers to open all new windows as browser tabs
Source: Pointy (same source as timdream)
I tried opening a new window using
window.open("lookup.htm","lookupWin", "height=400,width=500,resizable=false");
It works fine in IE, but in FF the pop up is still resizable. How can I disable this resizing in FF as well?
Read this one from mdc
Window functionality features
resizable
If this feature is set to yes, the new secondary window will be
resizable.
Note: Starting with version 1.4, Mozilla-based browsers have a window
resizing grippy at the right end of
the status bar, this ensures that
users can resize the browser window
even if the web author requested this
secondary window to be non-resizable.
In such case, the maximize/restore
icon in the window's titlebar will be
disabled and the window's borders
won't allow resizing but the window
will still be resizable via that
grippy in the status bar.
Starting with Firefox 3, secondary windows are always resizable
Bug 177838 - Make all popup windows resizable, ignoring resizable=no
Yes it doesn't work anymore. Try
<script type="text/javascript">
window.onresize = function()
{
window.resizeTo(500,500);
}
window.onclick = function()
{
window.resizeTo(500,500);
}
</script>
I don't think you can. Firefox (and some other browsers) just ignore the "resizable" setting.
you con configure dom.disable_window_open_feature.resizable to value false, in order to make window.open re sizable work.
Type about:config
Accept the warning
Search by typing resize and press enter ,
Look for dom.disable_window_open_feature.resizable
double click to change the value. false -> you can not resize the popup in firefox.