mattbontrager mattbontrager - 6 months ago 32
Javascript Question

Disable Browser Window Resize

For starters... I have no sinister intention of subjecting users to popups or anything like that. I simply want to prevent a user from resizing the browser window of a webpage to which they've already navigated (meaning I don't have access to / don't want to use;). I've been researching this for quite a while and can't seem to find a straightforward answer.

I felt like I was on track with something along the lines of:

$(window).resize(function() {
var wWidth = window.width,
wHeight = window.height;
window.resizeBy(wWidth, wHeight);
}); no avail. I have to imagine this is possible. Is it? If so, I would definitely appreciate the help.



You can first determine a definite size.

var size = [window.width,window.height];  //public variable

Then do this:



Q: Won't this cause an infinite loop of resizing? - user1147171

Nice question. This will not cause an infinite loop of resizing. The W3C specification states that resize event must be dispatched only when a document view has been resized. When the resizeTo function try to execute the second time, the window will have the exact same dimension as it just set, and thus the browser will not fire the resize event because the dimensions have not been changed.