Problem with the header in the window.location [closed]

-2

I have entered the following code in javascript, in a subdomain in atspace:

<meta charset="UTF-8"><body></body>
<div id="m"></div>
<script>
document.body.style.backgroundColor="black"
document.body.style.color="white"
window.location.replace("http://hypogenixv4.tk/")
</script>

What I want to achieve is to stop having an infinite reload on the page without losing the redirection that is made from the subdomain in atspace "18732409271905387123098542.atspace.com" to " link "

    
asked by DrCris 04.01.2017 в 21:19
source

1 answer

1

What you are missing is to verify which is the current location to execute or not redirect.

<script type="text/javascript">
    if(top.location.host != "18732409271905387123098542.atspace.com"){
        document.body.style.backgroundColor="black"
        document.body.style.color="white"
        window.location.replace("http://hypogenixv4.tk/")
    }
</script>

If you continue to generate a cyclical redirect, add a console log to your IFRAME in the following way.

<script type="text/javascript">
    console.log(top.location.host);
</script>

Once you add this script, try entering from the 2 domains to identify the string you should use in your validation.

    
answered by 06.01.2017 / 16:59
source