That won't work because it requires that a link be to both domains, an impossibility really, in order to pass the test. You could use || (logical or). But, if there are very many domains, your test would get quite long and unwieldy. It's already fairly inefficient using for in instead of for, adding all those indexOf() methods to it would bloat it even more.
Here's a fairly easy way to set things up that would be about as efficient as is possible for this. You need to configure the domains:
Code:
(function(){
var domains = ['one.com', 'two.com'],
lnks = document.links, i = lnks.length - 1, lnk;
domains = new RegExp( domains.join('|').replace(/\./g, '\\.') );
for (i; i > -1; --i){
if( (lnk = lnks[i] ).href && domains.test(lnk.href) ){
lnk.onclick = function(){ window.onbeforeunload = null; };
}
}
})();
You can add as many domains as you like to the array, ex:
Code:
var domains = ['one.com', 'two.com', 'three.com', 'four.com'],
Bookmarks