<!doctype html> <html> <head> <meta charset="utf-8"> <title>JavaScript DOM Element Position (Scroll Position Included) Example</title> </head> <body> <div>There are 4 buttons in this page, try to click them to get position.</div> <br style="line-height: 2em;"/> <button onclick="javascript:onButtonClick(this)">click me to get my position(1)</button><br /> <br style="line-height: 20em;"/> <div style="text-align: center;"><button onclick="javascript:onButtonClick(this)">click me to get my position(2)</button></div> <br style="line-height: 20em;"/> <button onclick="javascript:onButtonClick(this)">click me to get my position(3)</button><br /> <br style="line-height: 20em;"/> <div style="text-align: center;"><button onclick="javascript:onButtonClick(this)">click me to get my position(4)</button></div> <script src="position.js"></script> </body> </html>