I would like to know why document.write is not working based on screen resize funciton. Following is the code. Can anyone give me an explanation on this. Thanks in Advance
detectDevice=()=>{
let ww = window.innerWidth;
if(ww>500) {
document.write("Its Large Device");
}
else {
document.write("Its Small Device");
}
}
detectDevice();
window.addEventListener("resize", detectDevice);
Your code is using the wrong function:
let ww = window.innerWidth;
instead, use the following:
let ww = screen.width;