Embedded Iframe: Difference between revisions
Jump to navigation
Jump to search
Markkinchin (talk | contribs) No edit summary |
|||
| Line 70: | Line 70: | ||
<script> | <script> | ||
<nowiki> | <nowiki> | ||
var addUrlParamsToIframeSrcs = function () { | var addUrlParamsToIframeSrcs = function () { const validParameters = ["checkin","checkout","numnight","numadult","numchild","ownerid","propid","roomid","referer","redirect","lang","group","nogroup","category1","category2","category3","category4", "customParameter"]; const iframeAttrIdentifier = "ourIframe"; const currentUrl = new URL(window.location.href); let parametersString = ""; validParameters.forEach(parameter => { const parameterValue = currentUrl.searchParams.get(parameter); if (parameterValue !== null) { parametersString += "&" + parameter + "=" + parameterValue; } }); const iframes = document.getElementsByTagName("iframe"); for (let iframe of iframes) { let iframeSrc = iframe.getAttribute("data-src"); if (iframeSrc === null) { continue; } if (!iframeSrc.includes("?")) { iframeSrc += "?"; } iframeSrc += parametersString; iframe.setAttribute("src", iframeSrc) } }; addUrlParamsToIframeSrcs(); | ||
} | |||
addUrlParamsToIframeSrcs(); | |||
</nowiki> | </nowiki> | ||
</script> | </script> | ||