Summary
target="_blank" を使わないで新しいウィンドウでリンクを開くための手法.
Behaviour.js を利用すればより簡単,かつHTMLを汚さずに実装可能.
Sample
Source
var myrules = {
'.popup' : function(el){
var href = el.getAttribute('href');
if (href){
el.onclick = function(){ window.open(href); return false;}
el.onkeypress = function(){ window.open(href); return false;}
}
}
};
Behaviour.register(myrules);
<script type="text/javascript" src="behaviour.js"></script>
<a href="index.html">Normal</a>
<a class="popup" href="index.html">Pop up</a>
Reference
Behaviour : Using CSS selectors to apply Javascript behaviours
http://bennolan.com/behaviour/
via
cl.pocari.org - 2006-03-14
http://cl.pocari.org/2006-03-14-5.html