Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting min-width for resizing browser

Status
Not open for further replies.

shades44

Programmer
Jun 14, 2004
25
CA
Hi, i was wondering does anyone know how to set the minimum width a user can resize their window to? i dont want it to be resized to less than 400px say.. using javascript or whatever..
 
Something like this?
Code:
function checkSize()
{
  if (screen.innerWidth < 400)
  {
    resizeTo(400, screen.innerHeight);
    alert("To small!");
  }
}

window.onresize = checkSize;

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Code:
alert("To[red]o[/red] small!");

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
im not sure where you got 'screen.innerWidth' because it's undefined for me and i'm using IE6.. are you sure that attribute exists? and if it does is it not only measuring the width of the screen (not the browser)?
 
Try
Code:
screen.availWidth

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
[tt]screen.width[/tt] works in most browsers.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Doesn't that give you the width of the entire monitor?

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
yes, was I not paying attention? If that's the case, you'd need a window property, not a screen property.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top