我在我的网站上使用下面的代码。我想知道如果我需要jQuery来做,或者如果标准的JavaScript可以处理这个过程。我可以在没有jQuery的情况下执行此操作吗?
<script type='text/javascript'>
//<![CDATA[
$(window).load(function(){
$("a[href^='http']").click(function(event) {
event.preventDefault(); // prevent the link from opening directly
// open a pop for the link's url
var popup = window.open(this.href , "", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,status=no,width=340,height=10,left=250,top=175");
// popup.blur();
// window.focus();
}); }); //]]>
</script>
这是从这个页面:Pop Under on Click for RSS Feed - Javascript
jQuery只是JavaScript代码。 – 2012-01-05 12:46:52
当然标准的JS可以处理这个,但它更多的工作。我会去与jQuery。没有它,你必须遍历'document.getElementsByTagName('a')'并检查href是否有正则表达式。 – amiuhle 2012-01-05 12:48:48