I have the following code that should work, but in mobile it does not work in the chrome browser:
var permitir_mobile = true;
var mobileUrl = 'http://m.meusitemobile.com.br';
$(document).ready(function() {
var e = window;
redirectIfWidthLargeSize(e);
$(e).resize(function() {
redirectIfWidthLargeSize(e);
});
});
function redirectIfWidthLargeSize(e) {
if ($(e).width() < 1024 && permitir_mobile == true) {
e.location.href = mobileUrl;
}
if ($(e).width() < 1024) {
var el = '<li class="mob-url"><a href="' + mobileUrl + '">Versão Mobile</a></li>';
if ($('#menu_horizontal_base ul li.mob-url').length != 1) {
$('#menu_horizontal_base ul li:last').before(el);
$('footer nav ul li a').css('padding','30px 8px');
} else {
$('#menu_horizontal_base ul li.mob-url').remove();
}
}
};
It's interesting that if you do that on my cell phone screen, it shows 980 , that is, it's less than 1024 :
$(function() {
document.write('<p style="font-size:120px">'+$(window).height()+'</p>');
});
Then it should redirect in the condition below, but it is not what is happening:
if ($(e).width() < 1024 && permitir_mobile == true) {
e.location.href = mobileUrl;
}