API
We provide two: window message event api "@IMBOX/onHelpcenterPageLoad"
and "@IMBOX/onHelpcenterLinkClick"
They can be used to listen on helpcenter events. For example: if Helpcenter is iframed onto a page you might want to handle scroll on your host page when helpcenter changes its content.
@IMBOX/onHelpcenterPageLoad
Runs when helpcenter loads a page, either index
, category
, article
or search
page
it sends these parameters in event.data
{
type: "@IMBOX/onHelpcenterPageLoad",
payload: {
helpcenterId: 1, // your helpcenter id
page: "index", // `index`, `category`, `article` or `search`
},
},
Example code
<script>
window.addEventListener(
"message",
(event) => {
if (event.data.type === "@IMBOX/onHelpcenterPageLoad") {
// scroll to top of your page when event is fired
window.scrollTo({
top: 0
})
}
},
false
)
</script>
@IMBOX/onHelpcenterLinkClick
Runs when you click on a link in helpcenter.
it send these parameters in event.data
{
type: "@IMBOX/onHelpcenterLinkClick",
payload: {
href: "", // url of the link you pressed
},
},
Example code
<script>
window.addEventListener(
"message",
(event) => {
if (event.data.type === "@IMBOX/onHelpcenterLinkClick") {
// scroll to top of your page when event is fired
window.scrollTo({
top: 0
})
}
},
false
)
</script>