window.tryFunc = function(fName,args){ if(typeof window[fName]==='function'){ window[fName](args); }else{ if(args){ /* default behaviour is link */ if(args.href){ /* default link is target='_blank' */ window.open(args.href) } } } return false; /* inhibit default behaviour */ } window.tryGaOptOut = function(args){ /* gaOptout should have been defined by host */ if(typeof(gaOptout)=='function'){ gaOptout(); alert('Opt-out OK'); /* give feedback to user that opt-out has been performed */ }else if(typeof(gaOptOut)=='function'){ gaOptOut(); alert('Opt-out OK'); /* give feedback to user that opt-out has been performed */ }else{ /* gaOptOut is not defined. Just open args.href in another window (default behaviour) */ if(args){ if(args.href){ window.open(args.href); } } } }