开发者

Javascript opens new window and loads _self

This code loads the href into a new window and into self, why is this? Shouldn't return false; stop the de开发者_如何学Gofault click?

//get links in paragraphs
var first_p = $$('#client_work p a');

//get first link
var client_link = first_p[0];

if(client_link) {
    $(client_link).observe('click', function() {

        var mylink = window.open(client_link.href, 'new_window', '_self');
        return false;   

    })
}


Try this

//get links in paragraphs
var first_p = $$('#client_work p a');

//get first link
var client_link = first_p[0];

if(client_link) {
    $(client_link).observe('click', function(event) {

        var mylink = window.open(client_link.href, 'new_window', '_self');
        Event.stop(event);   

    })
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜