De la misma forma que podemos abrir ventanas secundarias mediante un enlace, también podemos cerrarlas pulsando un enlace. Al igual que en la apertura, también presentamos las tres formas posibles del enlace.
<html>
<head>
<TITLE>Cierre de ventanas secundarias.</TITLE>
<script language=javascript>
function cerrar_ventana(){
window.close()
}
</script>
</head>
<body>
<p><a href="javascript:close()">Cerrar</a></p>
<p><input type=button value="Cerrar" onclick="cerrar_ventana()"></p>
<p><a href="javascript:cerrar_ventana()"><img border="0"
src="http://www.uterra.com/archcodfuente/demos_img/imagen10.jpg"
width="125" height="125"></a></p>
</body>
</html>