BANO
BANO

Reputation: 89

Default variable value passed to function breaks script in IE11 but doesn't seem required

var fbOptout = function(reload=0) {
  reload = (typeof reload !== 'undefined') ?  reload : 0;
  var optoutWindowDisableKey = 'fb-disable';
  document.cookie = optoutWindowDisableKey + '=true; expires=Thu, 31 Dec 2999 23:59:59 UTC; path=/';
  window[optoutWindowDisableKey] = true;
  if(reload){
    location.reload();
  }
};

This is failing in IE11 due to the default variable value reload=0 passed along to the function.

Since the next line is

reload = (typeof reload !== 'undefined') ?  reload : 0;

this passing of the default value isn't even needed AFAIK or am I missing something?

Upvotes: 0

Views: 33

Answers (1)

Cerbrus
Cerbrus

Reputation: 72857

IE doesn't support default parameters.

Remove the reload=0:

var fbOptout = function(reload) {

You already have a check that assigns a default value to reload on the 2nd line, any way.

Upvotes: 2

Related Questions