I'm trying to read the referrer URL in order to redirect the user back to the details page. There might be a simpler way to do this, but basically I'm trying to read the incoming URL and redirect the user back to the project page once the print function is complete.
The problem I'm running into is the string that document.referrer returns. It does not look like the actual URL, but looks like this:
https://app.knack.com/appname?state=p%3Dgoogle%26s%3Dhome%26h%3Dhome&code=4/UADRJSVK5EPV9c5tX5pJMI_99b3i8jhLjuu8-eG_TxN6fpRzDdLy6mmwqFKIpKIs8uNl1BvOngvvs2pyVcCjxSE
And my script looks like this:
$(document).on('knack-scene-render.scene_96', function(event, scene) {
var referingPage = document.referrer;
setTimeout(function() {
window.print()
}, 900);
if (referingPage.indexOf("project-details") > -1) {
setTimeout(function() {
window.history.back()
}, 1000);
}
if (referingPage.indexOf("print-custom") > -1) {
setTimeout(function() {
window.history.go(-2);
}, 1000);
}
});