Want the call window to be automatically opened on your website? Here is a solution from our awesome devs:
(() => {
const listenerBlock = (selector, callback) => {
const uniqueBlocks = new Set();
const initialTargetNode = document.querySelector(selector);
if (initialTargetNode && !uniqueBlocks.has(initialTargetNode)) {
uniqueBlocks.add(initialTargetNode);
callback(initialTargetNode);
}
const mutationObserver = new MutationObserver((mutations, observer) => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node.nodeType === Node.ELEMENT_NODE) {
const targetNode = node.querySelector(selector);
if (targetNode && !uniqueBlocks.has(targetNode)) {
uniqueBlocks.add(targetNode);
observer.disconnect();
callback(targetNode);
}
}
}
}
});
mutationObserver.observe(document.body, {
childList: true,
subtree: true
});
};
listenerBlock('.eapp-click-to-call-window-component', (component) => {
if (component.classList.contains('eapp-click-to-call-window-show')) {
return;
}
const button = document.querySelector(
'.eapp-click-to-call-button-component'
);
if (button) {
button.click();
}
});
})();
Add this script to the Custom JS field on the Style tab of your Click to Call widget’s settings and you’ll be fine ![]()
Note: Custom JS doesn’t function in the preview mode, so you can check the result right on your website or through the Share Link
Guys, was this solution helpful? Let us know in the comments ![]()