Ad

How To Create A Floating Widget In Shopify Store Using Script Tags

- 1 answer

<script>(function() {
      function asyncLoad() {
        var urls = ["https:\/\/cdn.jsdelivr.net\/gh\/sureshkatikala\/[email protected]\/script.js?shop=autochatstore.myshopify.com"];
        for (var i = 0; i < urls.length; i++) {
          var s = document.createElement('script');
          s.type = 'text/javascript';
          s.async = true;
          s.src = urls[i];
          var x = document.getElementsByTagName('script')[0];
          x.parentNode.insertBefore(s, x);
        }
      };
      if(window.attachEvent) {
        window.attachEvent('onload', asyncLoad);
      } else {
        window.addEventListener('load', asyncLoad, false);
      }
    })();</script>

What should I put in the URL array link(script.js) to create a simple floating icon?

Ad

Answer

  var x = document.createElement("IMG");
  x.setAttribute("src", "https://image1.jdomni.in/jdomni_email/whatsapp_popup.png?output-format=webp");
  x.setAttribute("width", "48");
  x.setAttribute("height", "48");
  x.setAttribute("alt", "whatsapp icon");
  x.style = "bottom:0;right:0;position:absolute;z-index: 9999"
  document.body.appendChild(x);

This is how to put whatsapp icon

Ad
source: stackoverflow.com
Ad