I'm working on a page which I want when the user presses 'full version', force the width of the meta to make it look like the real web, the script does something like this:
((function ( $ ) {
var mobile = true;
var targetWidth = 1100;
$('.mobile-to-desktop').click(function(e) {
e.preventDefault();
$('meta[name="viewport"]').attr('content', 'width=' + targetWidth);
$('.watch-mobile').addClass('active');
window.sessionStorage.setItem("mobile", "false");
});
$(function() {
if (window.sessionStorage.getItem("mobile") === false) {
$('meta[name="viewport"]').attr('content', 'width=' + targetWidth);
$('.watch-mobile').addClass('active');
}
});
})(jQuery));
This works perfectly, the problem is that when I change php, the width changes again, and I wanted to see if it can be saved in some way.
I tried the sessionStorage and localStorage, but it does not work for me, it's just because I'm using something wrong.