Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
how to capture message shown in alert box

Here i need to get message that is displayed on alert box and click ok using javascript.

for example : alert("hello");

above that code displays message as hello which is coming from an other website I need to capture that message using javascript and script to get message and hit button.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

you can use this way:


function captureAlert() {
  // get all scripts
  var elem = document.scripts;

  // loop and check
  for (var i = 0, len = elem.length; i < len; i++) {

    var txt = elem[i].textContent.match(/alert\(['"]([^'"]+)['"]\)/);
    if (txt) { return txt[1]; } // if matched, return the alert value
  }
} 

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can just overwrite alert function.

var fn = alert;
alert = function(text) {
    document.write('<b>'+text+'</b>')
  alert = fn;
} 
<button onclick="alert('hello123')">Click</button>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda