flaab
flaab

Reputation: 573

Why is wrong with this JS function? Firefox does work but Chrome doesn't

Hi, I have been coding a little Js function that manipulates certains divs and elements. On firefox it works great, but it does not work in Chrome and halts all the Javascript. I simply don't find what is wrong. Could you be kind enough to let me know? Cookies were tested and work fine. Using Jquery. Thanks!

function RememberMe(addr, bycookie = false)
{
    // Cookie name
    cookiename = "LBETS";

    // Should we reset?
    reset = false;
    changed = false;

    // See if button pressed
    if($(".star_"+ addr).hasClass("active"))
    {
        $('#recent_tx').addClass("table-striped");
        $(".star_"+ addr).removeClass("active");
        reset = true;
    } else {
        $(".favstar").removeClass("active");
    }

    // Iterate rows
    $('#recent_tx tr').each(function(){
        if($(this).hasClass(addr))
        {
            if(reset)
            {
                $(this).removeClass('warning');
            } else {
                $(this).addClass('warning');
                changed = true;
            }
        } else {
            $(this).removeClass('warning');
        }
    })

    // Change class
    if(changed)
    {
        $('#recent_tx').removeClass("table-striped");
        $(".star_"+ addr).addClass("active");
        setCookie(cookiename, addr, 20*365);
    }

    // Reset 
    if(reset)
    {
        delCookie(cookiename);
    }
}

Upvotes: 0

Views: 62

Answers (1)

the system
the system

Reputation: 9336

Invalid syntax:

function RememberMe(addr, bycookie = false)

You can't do assignment of defaults in the function signature.

Firefox's JS engine allows this syntax, and it is likely coming in some form to ECMAScript 6.

Upvotes: 6

Related Questions