HTML redirect not working
Go to solution
Solved by C2dan88,
Been doing some testing and come up with a solution
Add your redirect code as an embed html element. When adding the element look in the properties & events panel and take note of the element id
And replace this line window.top.location.href = redirect;
with this
// message the parent window, with the redirect url window.parent.postMessage(redirect, "https://puzzlesofthemonth.wixsite.com"); // the origin has to match your sites domain
Now in the velo dev mode code panel select your page and add this code
import wixLocation from 'wix-location';
$w.onReady(function () {
// capture the message sent when the countdown timer reached zero
$w("#myEmbededHTMLElementID").onMessage( (event) => {
// the message contains the url to redirect to
let redirectLocation = event.data;
// redirect the user to the new location
wixLocation.to(redirectLocation);
});
});
Change myEmbededHTMLElementID to the id of your embed html element

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now