简体   繁体   中英

Syntax error in JavaScript typeof

Hello guys I'm having trouble with the following JS code:

 function <%=this.ClientID%>_CerrarClick()
    {
        if (typeof(<%=FuncionCerrar%>**)** == "function")
            <%=FuncionCerrar%>;
        return false;
    }

I need help to find out why that function throw syntax error.

You're missing ()

function <%=this.ClientID%>_CerrarClick()
    {
        if (typeof(<%=FuncionCerrar%>) === "function")
            <%=FuncionCerrar%>();
        return false;
    }

Edit

if FuncionCerrar is xx() then

var a='<%=FuncionCerrar%>';
    a=a.replace('()','');

 function <%=this.ClientID%>_CerrarClick()
        {
            if (typeof(a) === "function")
                a();
            return false;
        }

Assuming you do have function named <%=FuncionCerrar%> in your code. if you're not sure then :

if (typeof(window.<%=FuncionCerrar%>) === "function")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM