This would prevent unnecessary error on other pages of focus element not found.
var elementExists = document.getElementById("closepopbtn");
if(elementExists){
document.getElementById('closepopbtn').onclick = function() {
document.getElementById('popup').style.display = 'none'
};
}