open new window if a hasclass
Hello
I've links on an H2 (height 90px, it's for promotional boxes) with sometimes class="external", and these one I wish open it in a new window and the normal (without class="external") in the normal mode.
I can work it... could you help me?
My code:
-
<%-- start Block clickable --%>
<script type="text/javascript">
$(document).ready(function(){
$(".promo-box h2").click(function(){
if ( $("a").hasClass("external") )
window.open=$(this).find("a").attr("href");return false;
});
$(".promo-box h2").click(function(){
window.location=$(this).find("a").attr("href");return false;
});
</script>
<style type="text/css">
.promo-box h2 {
height: 5.75em;
cursor: pointer;
}
</style>
<%-- end Block clickable --%>
And the links code:
-
<div class="promo-box">
<h2 class="title-promo-box"><a href="http://writeon.domain.ch/" class="external">Write on</a></h2>
</div>
<div class="promo-box">
<h2 class="title-promo-box"><a href="promotion/">Promo</a></h2>
</div>
A lot of thx in advance,
Regards, Dominique