This function is triggered when a user is about to be redirected to one of the store pages. It works synchronously and accepts Page object so it can be used to identify the page where the user will be redirected and prevent the loading of this page by returning false value.

Ecwid.OnPageSwitch.add(function(page) {
    if (page.type === "PRODUCT") {
        window.location.href = "index.html?type=product&id=" + page.productId
        return false
    } else if (page.type === "CATEGORY") {
        window.location.href = "index.html?type=category&id=" + page.categoryId
        return false