in the menu we have a icon (chat), this should trigger a click (via Javascript) in the lower right corner (where the chat icon from hubspot is located). So the chat should be reachable from within the menu. but the URL from the chat (iframe) is different than that one from the website, which means it gets blocked by the browser (crossside scripting). My question, how can i toggle the chat icon from within the page if i DONT want to click on the icon in the lower right corner directly.
const element = document.querySelector('.element') // Use an ID or class to get your element
element.addEventListener('click', e => {
if (window.HubSpotConversations) {
window.HubSpotConversations.widget.open()
} else {
window.hsConversationsOnReady = [
() => {
window.HubSpotConversations.widget.open()
}
];
}
});
To close the chat you can use:
window.HubSpotConversations.widget.close();
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.
const element = document.querySelector('.element') // Use an ID or class to get your element
element.addEventListener('click', e => {
if (window.HubSpotConversations) {
window.HubSpotConversations.widget.open()
} else {
window.hsConversationsOnReady = [
() => {
window.HubSpotConversations.widget.open()
}
];
}
});
To close the chat you can use:
window.HubSpotConversations.widget.close();
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.