mailto using javascript

I want to open a new outlook mail template with the ‘To address’ whenever a user clicks an image. I have return my code in a html page(linked with the image), whenever it loads the javascript should open a new mail template. But the functionality is not working. Kindly let me know what is wrong in my code.

body onLoad="redirect()"

script language="JavaScript"

function redirect() 

      var email = "[email protected]"
      var mailto_link = 'mailto:' + email
      window = window.open(mailto_link, 'emailWindow')
      if (window && window.open && !window.closed)         
          window.close()

Leave a Comment