function makeHttpObject() { try {return new XMLHttpRequest();} catch (error) {} try {return new ActiveXObject("Msxml2.XMLHTTP");} catch (error) {} try {return new ActiveXObject("Microsoft.XMLHTTP");} catch (error) {} throw new Error("Could not create HTTP request object."); } var IusPrivacy = Object.create(null); function IusPrivacyManager() { var DEBUG = true; var getPageLanguage = function() { if(DEBUG) console.log("getPageLanguage"); var language = document.documentElement.lang; return language.split("-")[0]; }; var createElementFromHTML = function(htmlString,id) { if(DEBUG) console.log("createElementFromHTML"); var div = document.createElement('div'); if(id!=null) div.setAttribute("id",id); div.innerHTML = htmlString.trim(); return div; }; this.init = function(){ if(DEBUG) console.log("init"); const ctm_id = document.getElementById('IusPrivacyScript').getAttribute('ctm_id'); //const domain = new URL(); //const host = domain.replace('.','-'); const lang = getPageLanguage(); //const html = fetch('https://www.iusprivacy.eu/informativa-privacy-info-' + host + '-' +ctm_id+'?lang='+lang); const urlreq = 'https://www.iusprivacy.eu/informativa-privacy-info-' +ctm_id+'?lang='+lang; var request = makeHttpObject(); request.open("GET", urlreq, true); request.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); //request.setRequestHeader('Access-Control-Allow-Origin', '*'); request.send(null); request.onreadystatechange = function() { if (request.readyState == 4) { var element = document.getElementById('IusPrivacyContainer'); if (element) { element.innerHTML = request.responseText; } else { element = document.getElementsByTagName('body')[0]; var div = createElementFromHTML(request.re.responseText,'IusPrivacyContainer'); element.insertBefore(div,null); } } //document.getElementById('IusPrivacyContainer').innerHTML = request.responseText; }; }; } IusPrivacy = new IusPrivacyManager(); if (window.attachEvent) {window.attachEvent('onload', IusPrivacyOnload);} else if (window.addEventListener) {window.addEventListener('load', IusPrivacyOnload, false);} else {document.addEventListener('load', IusPrivacyOnload, false);} function IusPrivacyOnload(){ IusPrivacy.init(); } // inizializzazione: // // opzionale: nella pagina รจ possibile mettere un div: //
// per scegliere un punto preciso dove poter inserire la pagina di policy