var width = window.innerWidth; if(width ==undefined) { var D= document.documentElement; if(D) width= D.clientWidth; } var bannerId = Math.ceil(Math.random() * 2); console.log(bannerId); switch(bannerId) { case 1: document.write(""); break; case 2: document.write("X Dollscar"); break; case 3: break; }