<strong>第一种:下面的代码是针对jb51这个样式下的a都是在新窗口打开</strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="25909" class="copybut" id="copybut25909" onclick="doCopy('code25909')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code25909"> <br><script type="text/javascript"> <BR>jQuery(document).ready(function($) { $('.jb51 a').attr({target: "_blank"}); }); <BR></script> <br> </div> <br><br><strong>第二种: <br></strong><div class="codetitle"> <span><a style="CURSOR: pointer" data="17623" class="copybut" id="copybut17623" onclick="doCopy('code17623')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code17623"> <br><script src="http://code.jquery.com/jquery-latest.js"></script> <br><script type="text/javascript"> <BR>// open url in new a window <BR>$(document).ready(function(){ <BR>$("a").attr("target", "_blank"); <BR>}); <BR></script> <br> </div> <br>在新窗口中打开外部链接 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="95596" class="copybut" id="copybut95596" onclick="doCopy('code95596')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code95596"> <br>$('a[href^="http://"]') <br>.attr("target", "_blank"); <br> </div> <br><br><strong>第三种:如果想更方便的控制</strong> <br>XHTML 1.0 Strict 版本不支持 target="_blank" 属性,而使用 JQuery 能很好地解决这个问题,实现新窗口打开网页: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="35117" class="copybut" id="copybut35117" onclick="doCopy('code35117')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code35117"> <br>$('a[@rel$='external']').click(function(){ <br>this.target = "_blank"; <br>}); <br><br>/* <br>Usage: <br><a href="http://www.jb51.net/" rel="external">jb51.net</a> <br>*/ <br> </div>