I am working on a script where i want to restrict the resize of browser window when we resize the browser to width 320px. The screen should not shrink below 320px.
Here is my code!!
var waitForFinalEvent = (function() {
var timers = {};
return function(callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId" ;
}
if (timers[uniqueId]) {
clearTimeout(timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();
// Usage
$(window).resize(function() {
var output = $('.output');
$(output).text('RESIZING...');
// Wait for it...
waitForFinalEvent(function() {
$(output).text('EVENT FIRED!');
//...
}, 500, "some unique string");
});
Try this
$(window).resize(function(){
if ($(window).width() <= 320) {
window.resizeTo(300 ,$(window).height());
}
});
If your window is resized to less than 320 force the window to resize to 320 x whatever the current height is.
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.