Dear,
In the header builder, I’ve been able to create a button whose link is defined as javascript:void(Tawk_API.toggle())
and you can test this button called “CHATTEZ AVEC NOUS” on my site (desktop view).
Now I’m trying to create a similar button in the mobile navbar (mobile view) whose button shall be called “LIVE CHAT” and the link shall be exactly the same too. However, this is not working at all.
The code I’m giving above is fully 100% working. You can have trust of this because if you go on the mobile sidebar, there is a link called “CHATTEZ AVEC NOUS” where there the code is working.
Can you please tell me why the mobile navbar custom links does not support js script links? I need to make this work.
Just for more information, here is the code behind the js script link :
add_filter('walker_nav_menu_start_el', 'wpse_226884_replace_hash', 999);
/**
* Replace # with js
* @param string $menu_item item HTML
* @return string item HTML
*/
function wpse_226884_replace_hash($menu_item) {
if (strpos($menu_item, 'href="#"') !== false) {
$menu_item = str_replace('href="#"', 'href="javascript:void(Tawk_API.toggle())"', $menu_item);
}
return $menu_item;
}
Thanks
Attachments:
You must be
logged in to view attached files.