Pass id div to function.
function openWin(id) { var divText = document.getElementById(id).innerHTML; myWindow=window.open('','','width=200,height=100'); } <div id="pass">pass this to the new window</div> <a href="#" onclick="openWin('pass')" />click</a>
source share