Embedded Iframe: Difference between revisions

Jump to navigation Jump to search
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 validParameters = ["checkin","checkout","numnight","numadult","numchild","ownerid","propid","roomid","referer","redirect","lang","group","nogroup","category1","category2","category3","category4", "customParameter"];
     const iFrameAttrIdentifier = "ouriFrame";
     const iframeAttrIdentifier = "ourIframe";
 
     const currentUrl = new URL(window.location.href);
     const currentUrl = new URL(window.location.href);
     let parametersString = "";
     let parametersString = "";
Line 81: Line 82:
         }
         }
     });
     });
     const iFrames = document.getElementsByTagName("iFrame");
     const iframes = document.getElementsByTagName("iframe");
     for (let iFrame of iFrames) {
     for (let iframe of iframes) {
        if (iFrame.getAttribute(iFrameAttrIdentifier) !== null) {
             let iframeSrc = iframe.getAttribute("data-src");
             let iFrameSrc = iFrame.getAttribute("data-src");
             if (iframeSrc === null) {
             if (!iFrameSrc.includes("?")) {
                 continue;
                 iFrameSrc += "?";
             }
             }
             iFrameSrc += parametersString;
             if (!iframeSrc.includes("?")) {
             iFrame.setAttribute("src", iFrameSrc)
                iframeSrc += "?";
        }
            }
            iframeSrc += parametersString;
             iframe.setAttribute("src", iframeSrc)
     }
     }
}
}
addUrlParamsToiFrameSrcs();
addUrlParamsToIframeSrcs();
</nowiki>
</nowiki>
</script>
</script>