/ Published in: JavaScript

There's been a popular trend to use JavaScript to add target="_blank" to anchors with rel="external". So in the name of making everything in my site Prototype based I worked out a script to do just that.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> Event.observe(window, 'load', function() { $$('a[rel="external"]').each(function(link){ if(link.readAttribute('href') != '' && link.readAttribute('href') != '#'){ link.writeAttribute('target','_blank'); } }); }); </script>
URL: http://blog.ninedays.org/2008/04/07/change-rel-external-to-target-blank-using-prototype/
Comments
