document.addEventListener('DOMContentLoaded', function(event) { if (document.querySelectorAll('.webform-submission-form').length === 1){ fetch('https://ipgeolocation.abstractapi.com/v1/?api_key=5eeef8481bcc4208b4bc7c82ff8bdb21').then(function(response) { // Successfull fetch return as json return response.json(); }) .then(function(data) { // Data now contains the json if (data.country_code === "CA" || data.country_code === "US"){ document.querySelector("input[name=ipcountry]").value = data.country_code; }else if(data.country !== undefined){ document.querySelectorAll('.webform-submission-form')[0].parentNode.parentNode.innerHTML = `
Contact one of our regional managers who can help answer your questions about us, our programs, ÌðÐÄÊÓƵ Ste. Marie and provide application support by clicking here.
` ; } }) .catch(function(error) { // A Error occured console.log(error); }) } });