How to cancel web page link event

How to cancel web page link event

There is a popup page link in my web page, but I need to decide whether to popup page according to some cases. 
I want to add a javascript function to  as follow,
function checkSessionHasList(sessionHasPrList) {
    if (sessionHasPrList) {
    } else {
        var e = getEvent();
        if (e.preventDefault) {
        } else {
            window.event.returnValue = false;
On the link action, I add "onclick" event to call the js function, as following
But after compiled and deployed, the link on page is "onclick=True", and I use browser debug function to change link to "onclick = return false" 
and onclick="checkSessionHasList(false);", but they still can't work the popup page always popup,no matter what I do.

Please help.
In the other properties associated with the link it has a "Enabled" property.  move the Session.PreparePRList.Length <> 0 ....  code to this property.  If this occurs because of other actions on the page then do an ajax refresh to Enable/Disable the link.  This makes it much easier to manage than trying to do the javascript.
Hi jinsheng,

You cannot manipulate the onclick of links that are associated with popup editors. This is because the code of the popup editor manipulates the onclick to add the popup "logic".
But you can do like Rebecca said, prevent the link from being clicable by using the Enable property (or not rendering it at all) and I would also recommend to put the Popup_Editor block inside an "If". That way, when you do not want the link to do the popup, you won't have the popup code there.

There is no need to actually go mess with javascript for that.

João Rosado