if (window.addEventListener) { window.addEventListener("load", loadLogo, false); } else if (window.attachEvent) { window.attachEvent("onload", loadLogo); } function loadLogo(){ var bLinkExists = (document.getElementById("rhLogoCont").getElementsByTagName("a").length > 0); var sLogoHTML = "Gallo Rosso"; if (bLinkExists) { var cont = document.getElementById("rhLogoCont").getElementsByTagName("a")[0]; cont.innerHTML = sLogoHTML; }else{ var cont = document.getElementById("rhLogoCont"); cont.innerHTML = "" + sLogoHTML + ""; } }