Javascript打开新窗口并加载_self

时间:2010-04-20 19:35:53

标签: javascript prototypejs

此代码将href加载到一个新窗口并进入self,为什么会这样? 不应该返回虚假;停止默认点击?

//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;   

    })
}

1 个答案:

答案 0 :(得分:3)

试试这个

//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);   

    })
}