(function () { var integrate = function (){ console.log('integrate'); // url of the sript var scriptUrl = document.getElementById('uwm_kia_integration'); // get lineup key var dealerCode = getParameterByName('d', scriptUrl.src); // get model var model = getParameterByName( 'm' ); // get model var salesdemo = getParameterByName( 'salesdemo' ); if ( 'on' == salesdemo ) { var sString = '&salesdemo=on'; } else { var sString = ''; } // get intro status var introInfo = getParameterByName('intro', scriptUrl.src); // create iframe url var iframeUrl = '//uwmedia.us/cm_kia/front/?d=' + dealerCode + '&integration=&m=' + model +'&intro='+introInfo ; // main container element var uwmIframeContainer = document.getElementById('uwm_kia'); // create pym script and add it to the dom var pymScript = document.createElement('script'); pymScript.async = true; pymScript.src = '//uwmedia.us/cm_kia/js/global/front/pym.js'; // setup iframe uwmIframeContainer.innerHTML = "
"; // append pym script to main container uwmIframeContainer.appendChild( pymScript ); console.log('scriptUrl : ',scriptUrl,'dealerCode : ',dealerCode,'model : ',model,'salesdemo : ',salesdemo,'sString : ',sString,'sString : ',sString,'introInfo : ',introInfo,'iframeUrl : ',iframeUrl,'uwmIframeContainer : ',uwmIframeContainer); /** * Get param from URL by name * * @param name of the param you are looking for * @param url to look for the param in by name * * @return String value of the param found */ function getParameterByName(name, url) { if (!url) 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, " ")); } console.log('integrated'); } integrate(); })();