{TametheBots}

Noindex JavaScript Redirect Test

Testing if Search engines will see a JavaScript redirect if a

<meta name="robots" content="noindex">
is present.

This page does a fetch and redirects to the url that mock API returns:

<script>
                // when the DOM is fully loaded, run this function
                document.addEventListener('DOMContentLoaded', function () {
                   
                    // call a redirect API to get the URL to redirect to
                    fetch('/cont_api/api.php', {
                        method: 'POST',
                        body: JSON.stringify({
                            'action': 'fetchRedirect',
                        }),
                        headers: {
                            'Content-Type': 'application/json'
                        }
                    }).then(function (response) {
                        return response.json();
                    }).then(function (data) {
                        // redirect to the URL returned by the API
                        if (data.redirectUrl) {
                            window.location.href = data.redirectUrl;
                        } else {
                            console.error('No redirect URL found in response:', data);
                        }
                    }).catch(function (error) {
                        console.error('Error:', error);
                    });
                });
            </script>

Just before the </body>

< Back