Aşağıda yeni pencere açılıp , içeriğinin document.write ile oluşturulması örneği görülmektedir :
html> <head> <script language="javascript"> function openPopup(){ var newWindow=window.open("",'_blank', 'width=500,height=500'); newWindow.document.writeln("<html><body> <h1>Merhaba</h1></body></html>"); } </script> </head> <body> <form> <input type="button" onClick="openPopup()" value="open popup"></input> </form> </body> </html>
Düğme tıklandığında openPopup fonskiyonu çağrılır. Bu fonksiyon boş bir yeni sayfa açar ve pencerenin içeriğini document.writeln ile oluşturur. Yeni açılan pencerede H1 elementi ile yapılan "Merhaba " başlığı görülecektir