create LI autofill lib include dynamically

This commit is contained in:
Cappy Popp 2021-01-07 15:32:34 -05:00
parent 7322f88733
commit 9f93801cb5

View File

@ -1,6 +1,7 @@
<script> <script>
(function () { (function () {
var fillScript = document.createElement('script'), // the LI autofill script (client-side) var fillScript = document.createElement('script'), // the LI autofill script (client-side)
liAutoFillScript = document.createElement('script'),
iframeHolderDiv = document.createElement('div'), // so we can style location of button iframeHolderDiv = document.createElement('div'), // so we can style location of button
autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page
firstRow, firstRow,
@ -91,9 +92,15 @@
} }
}); });
// build LI autofill script
liAutoFillScript.src = 'https://www.linkedin.com/autofill/js/autofill.js';
liAutoFillScript.type = 'text/javascript';
liAutoFillScript.defer = true; // as opposed to default 'async'
// add the iframe to the holder div // add the iframe to the holder div
iframeHolderDiv.appendChild(fillScript); iframeHolderDiv.appendChild(fillScript);
autoFillLocation.prepend(iframeHolderDiv); autoFillLocation.prepend(iframeHolderDiv);
autoFillLocation.append(liAutoFillScript);
if (typeof MktoForms2 !== 'undefined') { if (typeof MktoForms2 !== 'undefined') {
MktoForms2.whenReady(function (form) { MktoForms2.whenReady(function (form) {