在javascript帮助中返回一个值

时间:2011-05-12 08:59:56

标签: javascript

我有这行代码:

<a href="#" id="profilelink" name="link2" onClick="viewornot(<?php echo $freechat_id ?>)"><?php echo $freechat_list; ?></a>
<!-- call the JS onclick and if OK was click do the message box and send button here -->

然后我有我的JS:

function viewornot(id) {
    var e = confirm('Do you want to view this profile?');
    if (e == true) {
        window.location.href = "http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id=" + id;
        window.location('http://www-rainbowcode-net/apps_dev.php/profiles/showprofilepersonal?id=' + id);
        return true;
    }
    else {
        var e2 = confirm('Do you want to send a message?');
        if (e2 == true) {
            //if ok was clicked send value back?? 
            return e2;  
        }
    }
}
在e2上的

确认:如果我点击OK,我怎样才能发回一个值(这样我就知道OK被点击了)这样我就可以生成消息框并发送按钮并完成其余的代码发送一个消息?

1 个答案:

答案 0 :(得分:0)

onClick="viewornot(...)"更改为onClick="return viewornot(...)"