have a href as follows:
<a class="eLink" href="http:www.abc.com">chk here xyz</a></li>
and javascript for “eLink” is as follows:
$("a.eLink").click(function link(evt) {
url = evt.target.href;
if (url.toString().toLowerCase().indexOf(".gov") <= 0) {
var tk = "Do you really want to continue?";
if (confirm(tk)) {
window.open(url, 'newwin');
}else{
window.open(url,'_self');
}
}
else
{ window.open(url, 'newwin'); }
return false;
});
});
Now my issue is when i click the href and click ‘cancel’ in the confirm button, my page goes to “abc.com”, but it shouldnt happen. My browser should remain the same. what script should i use in the else part so i remain the same page. thanks.
Just take the else out.
Sidenote, IE8 and lower doesn’t implement the
indexOffunction so you may want to patch it by writing your own implementation.