disable the maximize and minimize button

javascript United States
  • 18 years ago

    how to disable the maximize and minimize button of a browser in Javascript/VBscript?

  • 18 years ago

    If you're talking about the original window the user opened, you can't. However, there are some options if it's a window that you open via script. I will assume for the purposes of this answer that you're using JavaScript.


    The window.open() method allows you to specify in it's third parameter some options, one of which is the resizable option. Setting that to 0 will make it so the user cannot resize the window, so obviously they can't maximize it, either.


    Minimizing is trickier. There are only two ideas that come to me for this. The first is to use the window.showModalDialog() method. This opens a new window, and the user cannot go back to the window that opened it until it has been dismissed. (I'm surprised that this hasn't been abused more by the pop-up advertisers.) The problem with this is that it doesn't work in Netscrape 4.x. (Not sure about Netscrape 6.) So, if you care about Netscrape users, that's a problem.


    The other idea, which is really clunky and annoying but will work even for a window opened by the user is to set the onblur event for the window so that it re-focuses the window. You can do that like this:

    Code:
    window.onblur=new Function("window.focus()");

    This doesn't actually prevent the person from minimizing the window, but when they do, it will immediately restore itself. This can be kind of annoying, especially if the user's computer does a little animation for minimizing/restoring.


    Anyway, I hope that helps.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous