Load the Tiledesk widget conditionally with a Button

You can load the Tiledesk widget only if the Load Tiledesk button is clicked.
Example below:

<!DOCTYPE html>
<html>
  <head>
    <base href="./">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <script type="application/javascript">
      function loadTiledesk() {
              window.tiledeskSettings= 
              {
                  projectid: "63ac166e6cc0db0012b7b4b2"
              };
              (function(d, s, id) { 
                  var w=window; var d=document; var i=function(){i.c(arguments);};
                  i.q=[]; i.c=function(args){i.q.push(args);}; w.Tiledesk=i;                    
                  var js, fjs=d.getElementsByTagName(s)[0];
                  if (d.getElementById(id)) return;
                  js=d.createElement(s); 
                  js.id=id; js.async=true; js.src="https://widget.tiledesk.com/v5/launch.js";
                  fjs.parentNode.insertBefore(js, fjs);
              }(document,'script','tiledesk-jssdk'));

      }
  </script>

  </head>
  <body>
  <button id="load" onclick="loadTiledesk()">Load Tiledesk</button>
  </body>
</html>
1 Like