5
I have the following code that should work, but on mobile does not work in 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();
}
}
};
Interesting is that if you do this on the screen of my phone, it shows 980, that is, it is less than 1024:
$(function() {
document.write('<p style="font-size:120px">'+$(window).height()+'</p>');
});
So he should redirect in the condition below, but that’s not what’s going on:
if ($(e).width() < 1024 && permitir_mobile == true) {
e.location.href = mobileUrl;
}
Interesting, I’ll test this last one...
– Ivan Ferrer
I’ll put to test any of the cases, it has to roll.
– Ivan Ferrer
I found that the problem I’m having is lower, I’ll have to study one more in my code.
– Ivan Ferrer