Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!