// 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='; } else { var sString = ''; } // create iframe url var iframeUrl = '//uwmedia.us/cm_kia/front/?d=' + dealerCode + '&integration=&m=' + model + sString; // main container element var uwmIframeContainer = document.getElementById('uwm_kia'); // create pym script and add it to the dom var pymScript = document.createElement('script'); pymScript.src = '//uwmedia.us/cm_kia/js/global/front/pym.js'; // setup iframe uwmIframeContainer.innerHTML = "
"; // append pym script to main container uwmIframeContainer.appendChild( pymScript ); /** * 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, " ")); }