Answer the question
In order to leave comments, you need to log in
Can I disable the forced transition to the mobile version of the site on the client?
Good day,
is it possible to programmatically disable the forced transition to the mobile version of the site on the client if the browser recognizes the mobile device? Or force only the PC version to be enabled.
Answer the question
In order to leave comments, you need to log in
Yes, you can, I faced such a problem
See working code, you only need to include the js.cookie library
Here, an example from my code, I made a choice between the mobile version and the desktop version.
Just don't remove
the link to the library
<meta name="viewport" content="width=1280, initial-scale=0, maximum-scale=5.0, user-scalable=1" />
function toggleDesktop() {
Cookies.set('makeDesktop', 'yes', { expires: 7, path: '/' });
jQuery('#viewport').attr('content', 'width=1024, initial-scale=0, maximum-scale=5.0, user-scalable=1');
getRemoveCookie();
}
var getRemoveCookie = function(){
Cookies.set('removeInDesc', 'yes', { expires: 7, path: '/' });
jQuery('.header-line-red').append('<div><a hrerf="#" class="remCook">Обратно мобильная версия сайта</a></div>');
if(Cookies.get('removeInDesc')){
jQuery('.header-line-red').append('<div><a hrerf="#" class="remCook">Обратно мобильная версия сайта</a></div>');
}
jQuery('.remCook').on('click',function(){
Cookies.set('makeMobil', 'yes', { expires: 7, path: '/' });
jQuery('#viewport').attr('content', 'width=device-width, initial-scale=1');
jQuery('.remCook').remove();
});
if(Cookies.get('makeMobil')){
jQuery('#viewport').attr('content', 'width=device-width, initial-scale=1');
jQuery('.remCook').remove();
}
}
jQuery(function($) {
if(Cookies.get('makeDesktop'))
jQuery('#viewport').attr('content', 'width=1024, initial-scale=0, maximum-scale=5.0, user-scalable=1');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question