Opening Polaria from an item / button

Opening Polaria from an item / button

Written by Remi Delhaye
Last update: Thursday, Jan 02, 2025

To code a button or a menu navigation item on your site that will open the Polaria widget, you have 2 choices:

A. The URL

To automatically open the Polaria widget when someone lands on a page, please add “#chat-open” to the end of your URL.

Here is an example:

  • https://your-website.com/products#chat-open

Or simply in a DOM element:

  • <a href="https://your-website.com/products">My Website</a>

B. A button class

To open the Polaria widget from a button, you just have to add the “slaask-open-widget” class to the button.

Here is an example:

  • <button type="button" class="slaask-open-widget">Click Me!</button>

C. Using Slaask API functions

You can also use the Polaria API functions show() and hide() that allows you to open/close the chat.

Here is an example:

document.getElementById('my-button').addEventListener("click", function(event) {
  _slaask.show();
});

Notes:

  • The slaask-open-widget class also works in all the HTML tags that accept the “class” parameter.

  • Option A (The URL) only works for opening the live chat (widget) on web pages in the process of being loaded; it does not work for opening the live chat (widget) on an already opened page. However, if you want to open the live chat (widget) from an item/button on an already opened page, please refer to  option B (A button class).

  • These examples won't work if the widget has not been initialized.

Javascript API

12 articles in this category.
Written by Remi Delhaye.