Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda