简体   繁体   中英

Re-size a current browser window on minimize to specific width and height

How can I set height, width and set the position of the current browser window on minimize using jQuery like when user minimize the current browser it should display with a specific height and width in the left bottom (small window) corner of my screen (same as teams) does it possible?

You can't resize window if it's not opened with window.open()

And you can't distinguish between minimizing the window and switching to a different tab.


There are 2 ways:

  • open current window with window.open() at first.

or

  • open new window when current window is minimized.

code for the second one:

var url = "http://google.com";
var options =   "resizable"+
                ",height=500,width=500"+
                ",top=9999,left=0"; // left bottom

// on browser visibility changed
document.addEventListener("visibilitychange", function() {
    if(document.hidden){
        // on window minimized (or tab switched)
        window.open(url, "window name", options);
    }
    else{
        // on window restored
    }
}, false);

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