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

216
Vistas
JS script embedded in another website works with safari but do not work with chrome

I have a JS script embedded in another website. the target is to gram field contact and post it. my problem is that the script runs well on safari browser but not with chrome browser.

I tried: -clear cache on browsers

  • clear server Cache
  • clear Cloudflare Cache
  • checked that the file is reachable
  • no error on console

also tried to put alert to see the script is running. works of safari and do not show the alert in chrome even in incognito mode

here is the code:

var API_KEY = "key";
var API_DOMAIN = location.hostname;
var TOKEN = getParameterByName('token');

console.log('params');
console.log(API_DOMAIN);
console.log(TOKEN);


var reg_emailInputId = document.getElementById('reg_email');
// on keyup, start the countdown 
reg_emailInputId.onfocusout = function() {
  // init 
  var isValid = validateEmail(reg_emailInputId.value);

  // check if token is not empty 
  if ((TOKEN !== '' || TOKEN !== null) && isValid === true) {
    doneTyping(reg_emailInputId.value, '107');
  }
  console.log('listener_on');
};


function doneTyping(myInputValue, id) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      console.log(xhttp.responseText);
      console.log('send params');

    }
  };
  xhttp.open("POST", "domain", true);
  xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhttp.send(params);

}

function getParameterByName(name, url = window.location.href) {
  name = name.replace(/[\[\]]/g, '\$&');
  var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
    results = regex.exec(url);
  if (!results) return null;
  if (!results[2]) return '';
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

function validateEmail(email) {
  // init 
  var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;

  // check 
  if (email.match(mailformat)) {
    return true;
  } else {
    return false;
  }
}
<input type="text" id="reg_email" >

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

0

reg_emailInputId.onfocusout = function() { is not triggered in Chrome

Use an eventListener

var API_KEY = "key";
var API_DOMAIN = location.hostname;
var TOKEN = getParameterByName('token');

console.log('params');
console.log(API_DOMAIN);
console.log(TOKEN);


var reg_emailInputId = document.getElementById('reg_email');
// on keyup, start the countdown 
reg_emailInputId.addEventListener("focusout", function() {
  // init 
  var isValid = validateEmail(reg_emailInputId.value);

  // check if token is not empty 
  if ((TOKEN !== '' || TOKEN !== null) && isValid === true) {
    doneTyping(reg_emailInputId.value, '107');
  }
  console.log('listener_on');
});


function doneTyping(myInputValue, id) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      console.log(xhttp.responseText);
      console.log('send params');

    }
  };
  xhttp.open("POST", "domain", true);
  xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhttp.send(params);

}

function getParameterByName(name, url = window.location.href) {
  name = name.replace(/[\[\]]/g, '\$&');
  var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
    results = regex.exec(url);
  if (!results) return null;
  if (!results[2]) return '';
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

function validateEmail(email) {
  // init 
  var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;

  // check 
  if (email.match(mailformat)) {
    return true;
  } else {
    return false;
  }
}
<input type="text" id="reg_email" >

Especially for Dean:

<input type="text" id="reg_email" >
<script src="https://plungjan.name/SO/formval.js"></script>

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