开发者

Javascript opens new window and loads _self

开发者 https://www.devze.com 2022-12-27 19:08 出处:网络
This code loads the href into a new window and into self, why is this? Shouldn\'t return false; stop the de开发者_如何学Gofault click?

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

精彩评论

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