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

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?? please help me on this



Solution 1:[1]

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);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ???