Right, here's the deal, i'm new to javascript but have a little knowledge.

I recently added a document.write script to avoid spam on my email.

this is the code i used
Code:
<script language="JavaScript"><!--
var name = "NAME";
var domain = "host.com";

document.write('<a href=\"mailto:' + name + '@' + domain + '\" >');
document.write(name + '@' + domain + '</a>');

// --></script>
This above code works, but i want to add to it. I want an alert to appear once clicked. For this, i would use onClick

Code:
<script language="JavaScript"><!--
var name = "NAME";
var domain = "host.com";

document.write('<a href=\"mailto:' + name + '@' + domain + '\" onClick="window.alert('TEST')">');
document.write(name + '@' + domain + '</a>');

// --></script>
as soon as i add the onClick, the code does not work, the text / link doesn't even appear anymore.

What i would like to know is why this happens and how to successfully add onClick to the above code.

Thank you for your time.

Gilligan