var element = document.getElementById('myElement'); var topPos = element.getBoundingClientRect().top + window.scrollY; var leftPos = element.getBoundingClientRect().left + window.scrollX;