Search code examples
javascripthtmlmailto

HTML "mailto:" not opening in new window


This is my first post. I am trying to create a mailto link using 'templated' Javascript that takes the following excerpt from a JSON object:

var menu = {
"menu": [
     {
     "title": "let's talk",
     "link": "mailto:[email protected]"
      }
   ]
}

Where '+menu.menu[i].link+' is replaced by "mailto:[email protected]"

for (i=0; i<menu.menu.length; i=i+1) {
     entry = '<li><a href="'+menu.menu[i].link+'">'+menu.menu[i].title+' </a></li>';
}
$("#navmenu:last").append(entry);

When I click on the page (http://mrlevitas.github.io), nothing happens in either chrome or firefox.

Any advice please?


Solution

  • You might want to use the

    for (i=0; i<menu.menu.length; i=i+1) {
     entry = '<li><a href="'+menu.menu[i].link+'"  target="_BLANK">'+menu.menu[i].title+' </a></li>';
    }
    $("#navmenu:last").append(entry);
    

    It opens a new window.