Hello everyone,
I’ve tried searching for a solution only but I can’t seen to find one. I want to have an a link that pops up the chat when clicked, I’m currently using /?chat but this actually refreshes the page and opens the chat, not the desired affect.
How can I pop it up without refreshing the page?
Thanks!
Chris
Hi @cardboardhouse
Can you detail with a screenshot? I will support you figure out if you can detail that
It’s hard with a screenshot, but the steps are;
- link clicked
- Page refreshes, jumps to top of the page and chat pops up
Desired outcome;
- Link clicked
- Chat pops as, as you would if you clicked the chat bubble directly
Let try to find Live Chat button on your footer then change the href=“#” & add onclick=“openChatBox(event)”
Then try to add javascript openChatBox(event) function:
Hey, thanks for the reply!
Sorry but I’m not sure what to do;
- Where am I adding onclick=“openChatBox(event)”? It won’t let me add it to the link field on the right hand side
- Am I adding the script to my base.css?
-
Let try to edit code
-
let find the file header.liquid on your code then add it. Don’t use base.css because it only working for CSS code only
If you can’t do it. Let add me as collaborator to support you change it
I couldn’t figure out how to where to add onclick=“openChatBox(event)” 
Let add me as collaborator then I will try to update code for you. My email: huykon225@gmail.com
Thanks for the offer but I’m not really comfortable adding people I don’t know as collaborator
oh okay. it will difficult to me to support you complete it
No worries, I will definitely let you know if I can’t figure it out and we will have to try this!
let try to add JS code. It maybe works:
document.addEventListener('DOMContentLoaded', function() {
const chatLink = document.querySelector('a[href="/?chat"]');
if (chatLink) {
chatLink.addEventListener('click', function(event) {
event.preventDefault();
try {
const shopifyChatHost = document.querySelector('inbox-online-store-chat');
if (shopifyChatHost && shopifyChatHost.shadowRoot) {
const chatToggleButton = shopifyChatHost.shadowRoot.querySelector('button.chat-toggle');
if (chatToggleButton) {
chatToggleButton.click();
} else {
console.error('Shopify Inbox: Internal chat toggle button not found.');
}
} else {
console.error('Shopify Inbox: Chat host element not found or shadowRoot not accessible.');
}
} catch (error) {
console.error('Error programmatically opening Shopify Inbox:', error);
}
});
}
});
No it works!! I added it to main.js and works, thanks so much!