loadWidget('http://cdi-hq-apia.cdi-hq.com/Home', '#widgetContainer');
function loadWidget(url, targetSelector) {
fetch(url)
.then(response => response.text())
.then(html => {
const container = document.querySelector(targetSelector);
container.innerHTML = html;
// Execute any inline scripts
container.querySelectorAll('script').forEach(oldScript => {
const newScript = document.createElement('script');
if (oldScript.src) {
newScript.src = oldScript.src;
} else {
newScript.textContent = oldScript.textContent;
}
document.body.appendChild(newScript);
document.body.removeChild(newScript);
});
})
.catch(err => console.error('Widget load failed', err));
}



Leave A Comment