07-20-2023, 02:00 PM
I have embedded a 'Desktop View' link into my mobile webpage then a 'Mobile View' link on the desktop link if the user wishes to reverse their decision.
I have added the javascript to remove the CSS that would style the page in mobile view when the 'Desktop View' link is clicked and the cookie is being set as per normal. The problem is I'm using a boolean to check to see if the cookie is present when the user decides to switch back and forth between desktop and mobile views and it doesn't seem to be working. I have set up Console.Log to show when certain aspects are functioning and it appears that the check to see if the cookie is already present is being overlooked, its just setting a new cookie everytime and if the user clicks on a navigation link on the desktop view then goes back it reverts straight back to mobile view instead of the desktop view which is a result of the cookie not being read.
window.addEvent('domready', function () {
if ($('FooterDesktopView')){
console.log("desktopagain");
var windowcookie = getCookie('NonResponsiveVersion');
if (windowcookie == true){
removejscssfile("//static.uk-plc.net/library-cms/abd/bab95b16-20ba-4090-b883-1bee04bc58fc.css", "css");
$$('.remove-css').addClass('displaynone');
$$('.load-css').removeClass('displaynone');
}
else {
$$('.remove-css').each(function (el) {
el.addEvent('click', function () {
console.log("desktop");
removejscssfile("//static.uk-plc.net/library-cms/abd/bab95b16-20ba-4090-b883-1bee04bc58fc.css", "css");
$$('.remove-css').addClass('displaynone');
$$('.load-css').removeClass('displaynone');
setCookie('NonResponsiveVersion', 'desktop', '1');
});
});
}
}
});
Using the Console.log I'm finding that this section is being overlooked
console.log("desktopagain");
var windowcookie = getCookie('NonResponsiveVersion');
if (windowcookie == true){
removejscssfile("//static.uk-plc.net/library-cms/abd/bab95b16-20ba-4090-b883-1bee04bc58fc.css", "css");
$$('.remove-css').addClass('displaynone');
$$('.load-css').removeClass('displaynone');
}
else {
I should mention I'm using a CMS and Mootools. Can anybody help me resolve this problem?
I have added the javascript to remove the CSS that would style the page in mobile view when the 'Desktop View' link is clicked and the cookie is being set as per normal. The problem is I'm using a boolean to check to see if the cookie is present when the user decides to switch back and forth between desktop and mobile views and it doesn't seem to be working. I have set up Console.Log to show when certain aspects are functioning and it appears that the check to see if the cookie is already present is being overlooked, its just setting a new cookie everytime and if the user clicks on a navigation link on the desktop view then goes back it reverts straight back to mobile view instead of the desktop view which is a result of the cookie not being read.
window.addEvent('domready', function () {
if ($('FooterDesktopView')){
console.log("desktopagain");
var windowcookie = getCookie('NonResponsiveVersion');
if (windowcookie == true){
removejscssfile("//static.uk-plc.net/library-cms/abd/bab95b16-20ba-4090-b883-1bee04bc58fc.css", "css");
$$('.remove-css').addClass('displaynone');
$$('.load-css').removeClass('displaynone');
}
else {
$$('.remove-css').each(function (el) {
el.addEvent('click', function () {
console.log("desktop");
removejscssfile("//static.uk-plc.net/library-cms/abd/bab95b16-20ba-4090-b883-1bee04bc58fc.css", "css");
$$('.remove-css').addClass('displaynone');
$$('.load-css').removeClass('displaynone');
setCookie('NonResponsiveVersion', 'desktop', '1');
});
});
}
}
});
Using the Console.log I'm finding that this section is being overlooked
console.log("desktopagain");
var windowcookie = getCookie('NonResponsiveVersion');
if (windowcookie == true){
removejscssfile("//static.uk-plc.net/library-cms/abd/bab95b16-20ba-4090-b883-1bee04bc58fc.css", "css");
$$('.remove-css').addClass('displaynone');
$$('.load-css').removeClass('displaynone');
}
else {
I should mention I'm using a CMS and Mootools. Can anybody help me resolve this problem?