var sam = document.createElement("div"); sam.setAttribute("id","ad-3"); document.currentScript.parentElement.appendChild(sam); var linkNode = document.createElement("a"); linkNode.href = "//sam.setimedia.com/click/3/"; linkNode.target = "_blank"; var imgNode = document.createElement("img"); imgNode.src="http://oyungezer.com.tr/images/banners/eksik-sayi-728.jpg?v1"; linkNode.appendChild(imgNode); sam.appendChild(linkNode); var img = document.createElement("img"); img.src = "//sam.setimedia.com/receive/3/"; img.style.display = 'none'; sam.appendChild(img);