Reputation: 137
I would like to create _blank
with js HTML DOM, is it correct?
var a = document.createElement('a');
a.appendChild(document.createTextNode(contacts[i][j]));
a.setAttribute("href","http://www.facebook.com/", contacts[i][j],"target","_blank" );
td.appendChild(a);
Upvotes: 6
Views: 10074
Reputation: 8193
The setAttribute method accept only 2 parameters
var a = document.createElement('a');
a.appendChild(document.createTextNode(contacts[i][j]));
a.setAttribute('href', 'http://www.facebook.com/');
a.setAttribute('target', '_blank');
td.appendChild(a);
Upvotes: 1
Reputation: 3226
I think you should spilt the setAttribute
like:
a.setAttribute('href', 'http://www.facebook.com/');
a.setAttribute('target', '_blank');
According to the docs it takes only two parameters.
Upvotes: 10