lunes, 8 de julio de 2013

Calcular el tamaño (ancho y alto) del navegador automáticamente con jQuery

Calcular el tamaño (ancho y alto) del navegador automáticamente con jQuery

/**
 * Resize
 */
jQuery(document).ready(function($) {
    redimencionar();
    $(window).resize(redimencionar);
});
function redimencionar() {
    jQuery(document).ready(function($) {
        var height = $(window).height();
        var width = $(window).width();
        $('.wmb').html('Screen: ' + width + ' x ' + height);
    });
}
/**
 * End Resize
 */


//Redimensionamiento otro modo y más corto ;)
jQuery(document).ready(function($) {
    $(window).bind("load resize", function() {
        $('body').append('<div class="wmb" style="width: 150px;height: 150px;border: 1px solid green;color: green;font-family: Arial;font-size: 14px;position: fixed;left: 1px;top: 1px;z-index: 99999;"></div>');
        var height = $(window).height();
        var width = $(window).width();
        $('.wmb').html('Screen: ' + width + ' x ' + height);
    })
})

No hay comentarios:

Publicar un comentario