Skip or cancel onclick event in FF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vojvodin
    New Member
    • Sep 2011
    • 1

    Skip or cancel onclick event in FF

    Hi,
    I have linkbutton with JS validations on onclick event. I need cancel or skip this event dinamically on the client. I cant rewrite logic of this linkbutton. I need disable this event which depend on some conditions from another elements on the page(dropdown, textbox...).

    I need something like this.
    Example:
    function fired from other element, not from linkbutton.

    Code:
    function someFce(linkButtonID)
    {
    var linkButton = document.getElementById(linkButtonID);
    
    if (//firefox//)
    {
        if (//something//)
        {
           //desible linkbutton onclick event//
        }
        else
        {
           //enable linkbutton onclick event//
        }
    }
    Where is //desible linkbutton onclick event// and //enable linkbutton onclick event// I need help with the code. Thanks
    Sorry my bad english
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    follow this example
    Code:
    <script >
    function validation_function()
    {
     return false; // it wont switch anymore
    }
    </script >
    <a href='javascript:return validation_function()'>link</a>
    or
    Code:
    function validation_function()
    {
     if(condition support)
       window.location="http://desired.location.com"
     else
      return;
    }
    </script >
    <a onclick='validation_function()'>link</a>

    Comment

    Working...