Embedded Iframe: Difference between revisions
Jump to navigation
Jump to search
| (19 intermediate revisions by 4 users not shown) | |||
| Line 9: | Line 9: | ||
=Using an iFrame= | =Using an iFrame= | ||
Using iFrames are convenient but may have a sub optimal usability experience. | |||
Consider opening the booking page in a new tab instead of embedding it in an iFrame. | Consider opening the booking page in a new tab instead of embedding it in an iFrame. | ||
| Line 24: | Line 24: | ||
Consider opening the booking page in a new tab instead of embedding it in an iFrame. | Consider opening the booking page in a new tab instead of embedding it in an iFrame. | ||
If you do want to use an iFrame you can use following method to overcome the issue. This solution passes the widget data directly to the page holding the iFrame and relies on a special script installed on the page to pass the parameters to the iFrame. The iFrame then loads the booking page with the data from the widget. | |||
If you do want to use an iFrame you can use following method to overcome the issue. This | |||
This avoids the use of cookies to pass the data and should not be blocked by security or privacy settings. | This avoids the use of cookies to pass the data and should not be blocked by security or privacy settings. | ||
<span style="color:#fe746c;“ >{{#fas:exclamation-triangle}} </span>The solution requires that your website can have additional parameters added to your page URL without affecting their ability to load. | <span style="color:#fe746c;“ >{{#fas:exclamation-triangle}} </span>The solution requires that your website can have additional parameters added to your page URL without affecting their ability to load. | ||
<span style="color:#019cde; font-size: 150%;“ >{{#fas:info-circle}} </span> The principle here is to open your URL containing the iFrame directly with the booking page parameters added to your URL after a ?. The supplied script installed on your page will pass these URL parameters through to the iFrame which will apply them to the booking page within the iFrame. | |||
'''Step 1: Customize the widget''' | '''Step 1: Customize the widget''' | ||
| Line 59: | Line 59: | ||
'''Step 5: Install the iFrame and script on your website''' | |||
'''Step | |||
*Paste the modified code snipped into the HTML of your website where you want show the iFrame | *Paste the modified code snipped into the HTML of your website where you want show the iFrame | ||
*Add the following script directly after the iFrame end tag </iFrame> | *Add the following script directly after the iFrame end tag </iFrame> | ||
Example iframe: | |||
<div style="background-color: #f8f9fa !important; border: 1px solid #eaecf0;border-radius: 2px; padding: 1px 4px;"> | |||
<span style="background-color: #f8f9fa; border: 1px solid #eaecf0;border-radius: 2px; padding: 1px 4px;"><nowiki><iFrame data-src="https://beds24.com/booking2.php?propid=12345&referer=iFrame" width="800" height="2000" style="max-width:100%;border:none;overflow:auto;"><p><a href="https://beds24.com/booking2.php?propid=12345&referer=iFrame" title="Book Now">Book Now</a></p></iFrame></nowiki></span></div> | |||
Script: | |||
<div style="background-color: #f8f9fa !important; border: 1px solid #eaecf0;border-radius: 2px; padding: 1px 4px;"> | <div style="background-color: #f8f9fa !important; border: 1px solid #eaecf0;border-radius: 2px; padding: 1px 4px;"> | ||
<span style="background-color: #f8f9fa; border: 1px solid #eaecf0;border-radius: 2px; padding: 1px 4px;"><nowiki> | |||
<script> | <script> | ||
var addUrlParamsToIframeSrcs = function() { const validParameters = ["checkin", "checkout", "numnight", "numadult", "numchild", "ownerid", "propid", "roomid", "referer", "lang", "group", "nogroup", "category1", "category2", "category3", "category4", "customParameter"]; 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(); | |||
var | |||
</script> | </script> | ||
</nowiki></span> | |||
</div> | |||
Wordpress script: | |||
<div style="background-color: #f8f9fa !important; border: 1px solid #eaecf0;border-radius: 2px; padding: 1px 4px;"> | |||
<span style="background-color: #f8f9fa; border: 1px solid #eaecf0;border-radius: 2px; padding: 1px 4px;"><nowiki> | |||
<script>var addUrlParamsToIframeSrcs = function() { const validParameters = ["checkin", "checkout", "numnight", "numadult", "numchild", "ownerid", "propid", "roomid", "referer", "lang", "group", "nogroup", "category1", "category2", "category3", "category4", "customParameter"]; 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("src"); if (iframeSrc === null) { continue; } if (!iframeSrc.includes("?")) { iframeSrc += "?"; } iframeSrc += parametersString; iframe.setAttribute("src", iframeSrc) } }; addUrlParamsToIframeSrcs();</script> | |||
</nowiki></span> | |||
</div> | </div> | ||
| Line 106: | Line 93: | ||
When a guest clicks on "Book" for one of the listed properties they will be taken to the property booking page where they can book. | When a guest clicks on "Book" for one of the listed properties they will be taken to the property booking page where they can book. | ||
If you you have embedded property booking pages as well and want to redirect the guest to this page go to {#fas:cog}} (SETTINGS) BOOKING ENGINE > BOOKING PAGE > BEHAVIOUR and set "Booking Redirect" = "Multiple Property Only" and enter the URL of the property booking page followed by the redirect destination in "Booking Redirect Url" like this: | If you you have embedded property booking pages as well and want to redirect the guest to this page go to {{#fas:cog}} (SETTINGS) BOOKING ENGINE > BOOKING PAGE > BEHAVIOUR and set "Booking Redirect" = "Multiple Property Only" and enter the URL of the property booking page followed by the redirect destination in "Booking Redirect Url" like this: | ||
<code><nowiki> https://beds24.com/booking.php?propid=12341&redirect=https://www.mywebsite/propertyA</nowiki></code> | <code><nowiki> https://beds24.com/booking.php?propid=12341&redirect=https://www.mywebsite/propertyA</nowiki></code> | ||
| Line 176: | Line 163: | ||
==Page is insecure== | ==Page is insecure== | ||
Most likely you have a link to an image with is not securely hosted. | Most likely you have a link to an image with is not securely hosted. | ||
==Display problems on mobile== | ==Display problems on mobile== | ||