Hello, I am trying to remove this Javascript code from mobile, as it is affecting it.
window.onscroll = function() {myFunction()};
var header = document.getElementById("header");
var sticky = header.offsetTop;
function myFunction() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
I have added this code inside the head but it's still not working
function loadJs(isMobile) {
if (!isMobile) {
var fileref = document.createElement('script');
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", "mymenu.js");
document.head.appendChild(fileref)
}
}
var mobile = false;
function checkMobile() {
loadJs(mobile);
}
checkMobile();