views:

109

answers:

4

Hi guys

With help from you guys I now have a script that works like a charm.. The only thing I need now, is the script to open the URL in a new tab/window.

$(document).ready(function() {
    $("#onskeliste li").click(
    function()
    {
        window.location = $(this).attr("url");
        return false;
    });
    $('#onskeliste li a').click(function(e) {
        e.stopPropagation();
    });

})(jQuery);

Can you help me with this?? :-)

+5  A: 

Instead of using window.location you should use window.open() to open a new window (or tab) instead of loading the URL in the current one.

Window open() Method

Justin Niessner
window.open($(this).attr("url"));This worked! THank you!
Kenneth B
+2  A: 
$(function(){
    $('a.new-window').click(function(){
        window.open(this.href);
        return false;
    });
});
Alex Ivasyuv
A: 

Try this...

$(document).ready(function() {
    $("#onskeliste li").click(
    function()
    {
        window.open($(this).attr("url"));
        return false;
    });
    $('#onskeliste li a').click(function(e) {
        e.stopPropagation();
    });

})(jQuery);
Peter
A: 
$(document).ready(function() { 
    $("#onskeliste li").click( 
    function() 
    { 
        e.preventDefault(); 
        window.open($(this).attr('url'));
    }); 
    $('#onskeliste li a').click(function(e) { 
        e.preventDefault(); 
        window.open($(this).attr('url'));
    }); 

})(jQuery);
Sunny