$(document).ready(function(){ QelpCare.loadContent('www.tele2.nl/klantenservice/mobiel/toestelhulp/','static.customersaas.com/tele2-nl-clear/nl-nl/','Toestelhulp openen in nieuw tabblad','div.post__content'); }); var QelpCare = { loadContent(pastedUrl, cleanUrl, anchorText, divSelection) { var containers = document.querySelectorAll(divSelection); // Make sure both trailing slash and no trailing slash are supported var handleUrls = Array(); if (pastedUrl.endsWith('/')) { handleUrls[0] = pastedUrl; handleUrls[1] = pastedUrl.substring(0, pastedUrl.length - 1); } else { handleUrls[0] = pastedUrl + '/'; handleUrls[1] = pastedUrl; } containers.forEach(function (container) { for (var i = 0; i <= 1; i++) { var urlSelector = 'a[href*="' + handleUrls[i] + '"]'; var remoteLink = container.querySelector(urlSelector); if (remoteLink) { remoteLink.innerText = anchorText; var iframeSrc = remoteLink.getAttribute('href').replace('&', '&'); iframeSrc = iframeSrc.replace(handleUrls[i], cleanUrl); var iframe = document.createElement('iframe'); iframe.className = 'remote-content' iframe.src = iframeSrc; iframe.setAttribute('frameBorder', '0') iframe.style.height = (window.innerHeight / 1.1) + "px"; iframe.style.width = "95%"; container.insertBefore(iframe, null); var newWindow = document.createElement('a'); newWindow.href = iframeSrc; newWindow.innerText = 'Openen in nieuw tabblad'; newWindow.className = 'new-window'; newWindow.setAttribute('target', '_blank'); container.insertBefore(newWindow, iframe); break; } } }); } }