Is there any event javascript
that identifies when the browser resizes the page?
I'm having problems with page resizing with a FancyBox
window, which loses its dynamic changes and returns the setting when it was opened.
Is there any event javascript
that identifies when the browser resizes the page?
I'm having problems with page resizing with a FancyBox
window, which loses its dynamic changes and returns the setting when it was opened.
There is.
Javascript
var addEvent = function(elem, type, eventHandle) {
if (elem == null || typeof(elem) == 'undefined') return;
if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle, false );
} else if ( elem.attachEvent ) {
elem.attachEvent( "on" + type, eventHandle );
} else {
elem["on"+type]=eventHandle;
}
};
addEvent(window, "resize", function(){
console.log("a página foi redimensionada ");
});
jQuery
$(window).resize(function(){
console.log("a página foi redimensionada ");
})
You can do the following:
$(function(){
width_inicial=window.innerWidth;
heigth_inicial=window.innerHeight;
setInterval(function(){
if(window.innerWidth!=width_inicial || window.innerHeight!=heigth_inicial)
{
/* seu código */
alert('a página foi redimensionada');
}
},1000);
});