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:
- Call them
onOpen
, which means a reader still has to click to open the widget but once they do, the tab you select will load. Here's a sample that will open the widget to the Contact tab when it's opened:_ko19.onOpen = function() { _ko19.loadContact(); }
- Call them
onLoad
, which effectively opens the widget as soon as the page loads, open to that tab.Will open widget on page load
TheonLoad
method forces the widget to open as soon as the page loads. If you want readers to have to select a button or link to open the widget, don't use this method._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>