使用Prototype将Rel External更改为Target Blank
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Prototype将Rel External更改为Target Blank相关的知识,希望对你有一定的参考价值。
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.
<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>
以上是关于使用Prototype将Rel External更改为Target Blank的主要内容,如果未能解决你的问题,请参考以下文章