vendredi 8 juin 2018

If image then run code

x.php just shows a external image.
2.php shows that external image in span with id X.

I would like to redirect users if a certain image apears.
I tested my code but it doesnt seem to work. Why & can someone help me solve this problem?

x.php

<?php
if ($add == 1){
  echo '<img src="https://i.imgur.com/tXuj74u.png"/>'; 
}
?>

2.php

<script>
window.setInterval(function() {  
    httpGetAsync('X.php', function(text) {  
        if (document.getElementById("X").innerHTML == '<img src="https://i.imgur.com/tXuj74u.png"/>') { 
        window.open("https://www.google.com", "_blank");
        } 
    });  
}, 4000);
</script>
<span id="X"><?php include 'X.php'; ?></span>

Aucun commentaire:

Enregistrer un commentaire