Help me understand [removed]void(null)

前端 未结 4 1522
旧时难觅i
旧时难觅i 2021-02-19 11:15

can someone please help me with this javascript:void(null) I found it used in link buttons as follows



        
4条回答
  •  抹茶落季
    2021-02-19 11:59

    Basically what happens is the onclick the function ProcessResponse() is called and the href is set to javascript:void(null) to disable the default behaviour of the link.

    Most developers are simply used to writing this too:

    Accept Data
    

    Example:

    Suppose we have this link in place:

    Accept Data
    

    Note that href is set to www.google.com but when you actually click on that link, it would simply call the ProcessResponse() function and won't go to www.google.com because the return false put after ProcessResponse() disables the default behavior of the link that is going to www.google.com. Same is the case for the link you have posted.

提交回复
热议问题