S
S
Sinner32020-01-29 18:57:51
CRM
Sinner3, 2020-01-29 18:57:51

How to call crm form Bitrix 24 when closing the site?

In Bitrix24 out of the box there are several scripts for launching the form code below
on the page

<script id="bx24_form_inline" data-skip-moving="true">
        (function(w,d,u,b){w['Bitrix24FormObject']=b;w[b] = w[b] || function(){arguments[0].ref=u;
                (w[b].forms=w[b].forms||[]).push(arguments[0])};
                if(w[b]['forms']) return;
                var s=d.createElement('script');s.async=1;s.src=u+'?'+(1*new Date());
                var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
        })(window,document,'https://missp.bitrix24.ru/bitrix/js/crm/form_loader.js','b24form');

        b24form({"id":"2","lang":"ru","sec":"ehiv9q","type":"inline"});
</script>

Click on a button or link
<script id="bx24_form_button" data-skip-moving="true">
        (function(w,d,u,b){w['Bitrix24FormObject']=b;w[b] = w[b] || function(){arguments[0].ref=u;
                (w[b].forms=w[b].forms||[]).push(arguments[0])};
                if(w[b]['forms']) return;
                var s=d.createElement('script');s.async=1;s.src=u+'?'+(1*new Date());
                var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
        })(window,document,'https://missp.bitrix24.ru/bitrix/js/crm/form_loader.js','b24form');

        b24form({"id":"2","lang":"ru","sec":"ehiv9q","type":"button","click":""});
</script><button class="b24-web-form-popup-btn-2">Мы перезвоним вам</button>

Popup window - auto show:
<script id="bx24_form_delay" data-skip-moving="true">
        (function(w,d,u,b){w['Bitrix24FormObject']=b;w[b] = w[b] || function(){arguments[0].ref=u;
                (w[b].forms=w[b].forms||[]).push(arguments[0])};
                if(w[b]['forms']) return;
                var s=d.createElement('script');s.async=1;s.src=u+'?'+(1*new Date());
                var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
        })(window,document,'https://missp.bitrix24.ru/bitrix/js/crm/form_loader.js','b24form');

        b24form({"id":"2","lang":"ru","sec":"ehiv9q","type":"delay","delay":5});
</script>

But there is no call script when the site is closed, maybe someone has already implemented it or knows how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Loki9928, 2020-12-16
@Loki9928

This is the only option that comes to my mind

window.onbeforeunload = function() {
               b24form({"id":"2","lang":"ru","sec":"ehiv9q","type":"delay","delay":5});
          return true;
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question