Hello,
I want to make a window, not a pop-up, to resize to a certain size when it’s loaded. The problem is I want it to resize to content, not the whole window that includes tool bars and such, as window.resize does.
Is this possible? I’d appreciate any input. Thank you!
Sorry tink, but that question doesn’t make a lot of sense. Do you have a content container that you are referring to as a “window”? If so that can be done fairly easily. Please elaborate, perhaps with a link to something similar to what you are trying to accomplish.
Hi actionAction,
Sorry I wasn’t being clear.
Please see this link.
I would like it to resize to the orange box, not the whole browser. The orange box is 648 x 576. When I use this function, window.resizeTo(648,576); it would cut the top and bottom portion off because it’s including address bar, menu bar, tabs, etc. Right now, I have it as window.resizeTo(648,750); but depending on which browser you use, the amount of black background you see varies.
Let me know if it makes sense.
Thanks!
Hello tink, thanks for the clarification. I will start by saying that you don’t want to do this, people really hate it when you resize their browser window without asking. Frankly…it’s pretty rude, they may have other tabs open that don’t use this dimension, and will most definitely just maximize their browser and wonder why your page did that. Just a little guidance. I suggest you use window.open and set the size to be what you want it to be, and not allow it to be resized.
Here is a snippet from a DOM class I made that you can use. It opens a centered chromeless popup:
function w( wObj )//({width:int,height:int,url:string})
{
var screen_height = window.screen.availHeight;
var screen_width = window.screen.availWidth;
var left_point = parseInt(screen_width/2)-(wObj.width/2);
var top_point = parseInt(screen_height/2)-(wObj.height/2);
win = window.open(wObj.url,"win","width="+wObj.width+",height="+wObj.height+",top="+top_point+",left="+left_point+",toolbars=0,location=0,statusbar=0,resizable=0");
}
You can call it any number of ways:
<a href="#" onclick="javascript:w({url:'mypage.html', width:648, height:750});" />Open Site</a>
//or if you want to bypass having a user click something, do something like this:
<body onload="javascript:w({url:'mypage.html', width:648, height:750});">
or
window.onload = w({url:'mypage.html', width:648, height:750});
Hope this helps you!
Yes, I completely agree it’s rude and annoying… I didn’t want to do this either but my client insisted. I also suggested pop up as you did but this is what they want. :vamp:
Just out of curiousity, though… is this possible at all?
In any case, thanks for the input!
No problem tink! :thumb:
Ah yes, clients… Anyway, no, it’s not possible to get rid of the chrome without creating a new window. Why don’t you use relative values in your css? Set the content container to be 80% so that leaves 10% black on each side, no matter what size the browser window is. Just a thought…good luck!