css - Replacing with Javascript Conditional -
i'm using javascript replace of links registration messages:
<script> function replacelinks() { var links = document.queryselectorall('.restore a:link'); (var = 0; < links.length; i++) { links[i].innerhtml = 'download register here.'; links[i].href = 'register.php'; } } </script>
the problem:
it's replacing thumbnail images (that link full-size images), too. can't apply specific css selector links because i'm using vbulletin , apply both links , images inside of post content.
does know how can...
forbid javascript applying links end .jpg, .gif, etc -- rewrites links, , not thumbnails link full sized images?
you can check link href simle regexp , proceed if test false:
function replacelinks() { var links = document.queryselectorall('.restore a:link'); (var = 0; < links.length; i++) { if (/\.(png|jpe?g)$/.test(links[i].href)) continue; links[i].innerhtml = 'download register here.'; links[i].href = 'register.php'; } }
Comments
Post a Comment