How to make conditional click action on button?

  • 30 March 2021
  • 0 replies
  • 13 views

I want to handle conditional click action with custom javascirpt.
i just want to distinguish browser and handle action by js not only unbounce click action.
how can i do this?

const test = document.querySelector('#unbounce-button');
test.onclick = () => {
  if (
    (navigator.appName == 'Netscape' &&
      navigator.userAgent.toLowerCase().indexOf('trident') != -1) ||
    navigator.userAgent.toLowerCase().indexOf('msie') != -1
  ) {
    // IE : activate custom action and ignore click action from unbounce
  } else {
    // other browser : activate click action from unbounce
  }
};

0 replies

Be the first to reply!

Reply