在问这个问题之前,我已经彻底搜索了一个答案,但一无所获。我希望我的AdBrite广告在点击时在新窗口中打开。请帮我。这是我的广告代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>AdBrite Ad Test</title>
</head>
<body>
<script>
var AdBrite_Title_Color = '025581';
var AdBrite_Text_Color = '2D2D2D';
var AdBrite_Background_Color = 'FFFFFF';
var AdBrite_Border_Color = 'FFFFFF';
var AdBrite_URL_Color = '0375B1';
try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==''?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe='';var AdBrite_Referrer='';}
</script>
<script type="text/javascript">
document.write(String.fromCharCode(60,83,67,82,73,80,84));
document.write(' src="http://ads.adbrite.com/mb/text_group.php?sid=1860199&zs=3330305f323530&ifr='+AdBrite_Iframe+'&ref='+AdBrite_Referrer+'" type="text/javascript">');
document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script>
<div><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=1860199&afsid=1" style="font-weight:bold;font-family:Arial;font-size:13px;">Your Ad Here</a></div>
</body>
</html>
答案 0 :(得分:0)
您可以使用jquery 'attribute startswith' selector
$('a[href^="http://www.adbrite.com"]').live('click',function(){
$(this).attr('target','_blank'); return true;
});
这假设链接看起来像示例代码中的最后一个<a>
元素。
.live()确保稍后创建的链接也会获得click事件。您应该检查al urls是否以http://www.adbrite.com
开头,否则他们将无法获得点击事件。