Reputation: 27
I Want do a click to an existing <a href="">
Code :
var els = document.getElementsByTagName("a");
for (var i = 0, l = els.length; i < l; i++) {
var el = els[i];
if (el.href === 'https://www.messenger.com/t/someperson') {
el.click;
}
}
Upvotes: 1
Views: 962
Reputation: 323
You can try window.location
var els = document.getElementsByTagName("a");
for (var i = 0, l = els.length; i < l; i++) {
var el = els[i];
if (el.href === 'https://www.messenger.com/t/someperson') {
window.location = el.href;
}
}
Upvotes: 1
Reputation: 980
Try this:
var els = document.getElementsByTagName("a");
for (var i = 0, l = els.length; i < l; i++) {
var el = els[i];
if (el.href === 'https://www.messenger.com/t/someperson') {
el.click();
}
}
Upvotes: 1