@rollin
To make an iframe redirect with cookies, you can use JavaScript to set a cookie on the parent page and then read that cookie in the iframe to determine the redirect URL. Here's a step-by-step guide on how to do this:
1
|
document.cookie = "redirectUrl=https://www.example.com"; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Function to get cookie value by name function getCookie(name) { var value = "; " + document.cookie; var parts = value.split("; " + name + "="); if (parts.length == 2) return parts.pop().split(";").shift(); } // Get the redirect URL from the cookie var redirectUrl = getCookie("redirectUrl"); // Redirect the iframe to the specified URL if (redirectUrl) { window.location.href = redirectUrl; } |
1 2 3 4 |
<iframe src="your-iframe-url" id="myIframe"></iframe> <script> // Your script to read the cookie and redirect </script> |
By following these steps, you can use cookies to redirect an iframe to a specified URL. Keep in mind that the same-origin policy may restrict your ability to successfully read cookies across different domain or subdomain boundaries.