0

I am trying to create a button that will resize the browser window on clicking.From what I've seen this is definitely possible. Using JQuery I have written the following code:

$('.resize').click(function(){
window.resizeTo("300px", "300px");
});

To affect the following html:

<button class="resize">click me</button>

But when clicked, the button does nothing. Any ideas?

ladanta
  • 459
  • 2
  • 6
  • 18

1 Answers1

2

Based off your comment, the question has changed. My edit:

You cannot resize the current global window object in most modern browsers. You can refer to the following two links on why that is considered bad practice, and possible alternatives (Perhaps opening your application through a popup window to begin with?):

An alternative that I haven't seen around this topic is to use CSS @media screen{ } to detect and implement features based on how big the window is. Try doing some research on that.

Community
  • 1
  • 1
Xenyal
  • 2,136
  • 2
  • 24
  • 51
  • I pasted the wrong snippet sorry, the class is corresponding correctly! Silly of me. The function itself still doesn't work though :/ – ladanta Dec 12 '14 at 22:41
  • `window.resizeTo` will not work in Chrome or Opera. Firefox also has the option from the user's side to deactivate this function. – Xenyal Dec 12 '14 at 22:44
  • Fair enough. :( Do you know is there any other option for this? I am creating an interactive application that works best at a certain window size. – ladanta Dec 12 '14 at 22:46
  • @MarcMurray Check my edits above. You can try displaying a warning to the client when their window is bigger than what you want. – Xenyal Dec 12 '14 at 22:50