redirect
3 years ago in HTML
<html>
<head>
<title>Kuvera</title>
</head>
<body>
<h1>Redirecting to Kuvera App</h1>
</body>
<script type="text/javascript">
window.kuveraCanClose = true;
window.addEventListener('load', (event) => {
// GET PARAMS
const url = new URL(window.location.href);
const params = Object.fromEntries(new URLSearchParams(url.search));
// MOBILE
// POST MESSAGE: TO OPENER
params.message = 'redirect_complete';
const interval = setInterval(_ => {
if (window.webkit) {
window.webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify(params))
clearInterval(interval)
}
}, 200);
setInterval(_ => {
if (window.redirect_url) {
window.location.href = window.redirect_url
}
}, 200)
// POST MESSAGE: TO OPENER
if (window.opener) {
window.opener.postMessage(params, "*");
}
// ELSE
// FIGURE OUT WHERE TO REDIRECT
const redirect_to = params.redirect_to ?
params.redirect_to :
'https://kuvera.in/cart/thankyou';
// AUTO REDIRECT / FALLBACK
//window.setTimeout(_ => (window.location.href = redirect_to), 1000);
});
</script>
</html>