Open widget to specific tab

By default, the widget will:

  • Open to the Recommended tab if there are any recommended articles for the current page
  • Open to the Knowledge tab if there are no recommended articles for the current page

You can open the widget to a specific tab every time by using one of these methods:

  • _ko19.loadContact(); - will open directly to Contact tab
  • _ko19.loadKnowledge(); - will open directly to the Knowledge tab
  • _ko19.loadRecommended(); - will open directly to the Recommended tab

There are two ways to use these methods:

  1. You can call them onOpen, which means a reader still has to click to open the widget but once they do, that tab will load. Here's a sample that will open the widget to the Contact tab when it's opened:
    _ko19.onOpen = function() {
           _ko19.loadContact();
    }
  2. You can call them onLoad, which effectively opens the widget as soon as the page loads, open to that tab.
    Note: this will force the widget to open as soon as the page loads. If you want readers to have to click a button or link to open the widget, don't use this method.
    Here's a sample that will open the widget to the Recommended tab when the page loads:
    _ko19.onLoad = function() {
            _ko19.loadRecommended();
    }

In either case, you'll add the onLoad or onOpen call into the Widget embed script between the end of the last default function and the closing </script> tag. For example:

<script type="text/javascript">
    var _ko19 = _ko19 || {};
    _ko19.__pc = '5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa';
    _ko19.base_url = '//test.knowledgeowl.com';
    
    !function() {
        var ko = document.createElement('script');
        ko.type = 'text/javascript';
        ko.async = true;
        
        ko.src = `${_ko19.base_url}/widget-app/assets/js/load.js`;
        document.head.appendChild(ko);
    }();    
  
      _ko19.onOpen = function() {
        _ko19.loadContact();      
    }
</script>