Get the text of a php

1

I have a php code where I print an'echo' at the end of my entire process ie:

<?php
 /*
 aqui va todo el proceso...
 */
  echo "Proceso teminado";
 ?>

I want to know if you can close the browser window once that text appears. I know beforehand that there is a code in JS that is closing process window.close(); the issue is that I want to run it automatically, as soon as the text ends the sale, is there a way to achieve it ?. Greetings.

    
asked by Artes 20.10.2018 в 21:04
source

1 answer

1

You can assign the message to an element and then with JS find that element and evaluate its value:

window.onload = () => {
  setInterval(()=>{
    let elem = document.getElementById('status');
    if(elem.innerText === "Proceso terminado") {
      window.location.assign("https://www.google.com.mx");
    }
  },1000);
}

The code is executed every second with the function:

setInterval()

This option allows you to redirect the user to another page.

    
answered by 20.10.2018 / 22:20
source