简体   繁体   中英

Resizing window on button click?

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM