I’m using window.location.replace() to redirect to a new page (same domain as the original). However, I need to run some jquery code after the redirection has finished. I can’t simply embed the code I want to run on the target page, since it needs data I have on the current context.
Is there a way of setting a trigger similar to document.ready but on the new page?
My first idea was
window.location.replace(data.redirect);
$(document).ready(
function() {
(use data variable from outer context)
}
);
But this won’t work as the function will be run on the current document.
Is this even possible?
Nope, not possible, but if you’re on the same domain, have you considered putting that information in a cookie?