laylo
09-20-2011, 05:50 PM
i got this code which will open a new link in a new window.
<script type="text/javascript">
$(function(){
$(".popup").click(function(event){
event.preventDefault();
var href = $(this.)attr("href");
var width = $(this.)attr("data-width");
var height = $(this.)attr("data-height");
var popup = window.open (href, "popup",
"height=" + height +",width=" + width + "");
});
});
</script>
This is the html which it should be targeting.
<li><a href="http://www.google.com" data-width="600" data-height="400" class="popup">Latest Posts</a></li>
i'm just starting out with js/jq. i dont know what's wrong. :(
thanks for your help. p.s I have explicitly tried the onclick approach where I already gave the function a name followed by () between quotes but same thing happens. The link opens in the same window.
<script type="text/javascript">
$(function(){
$(".popup").click(function(event){
event.preventDefault();
var href = $(this.)attr("href");
var width = $(this.)attr("data-width");
var height = $(this.)attr("data-height");
var popup = window.open (href, "popup",
"height=" + height +",width=" + width + "");
});
});
</script>
This is the html which it should be targeting.
<li><a href="http://www.google.com" data-width="600" data-height="400" class="popup">Latest Posts</a></li>
i'm just starting out with js/jq. i dont know what's wrong. :(
thanks for your help. p.s I have explicitly tried the onclick approach where I already gave the function a name followed by () between quotes but same thing happens. The link opens in the same window.