Add iframe url as param: remote domain

This demo works for HTTP and HTTPS. You are on HTTPS right now Please click here to get to the HTTP version.

< back to the overview of "Add iframe url to parent"

Example 33: Add iframe URL as param remote domain + use a prefix for shorter parameters

This example shows how the current iframe URL is added to the parent URL as parameter if the iframe is on the REMOTE domain and the external workaround can be used. This features is only available in the pro version of the advanced iframe.

To make it easier to copy/paste the examples most examples are fully configured in the shortcode directly. I use use_shortcode_attributes_only="true" that none of the settings from the administration are used.

The following two settings are the important ones:

  • map_parameter_to_url="page" - This enables that the value of parameter page should be opened inside the iframe. IMPORTANT: "page" is a reserved word and should actually not be used here! WordPress 5.5 started to do a redirect here. The plugin has a special setting "Fix WordPress 5.5 page parameter change" to still enable the usage of page as many users who use this only need to enable this and don't have many invalid links!
  • add_iframe_url_as_param="remote" - This enables that the iframe url is on the remote domain and should be added to the parameter defined at map_parameter_to_url. In this example the var add_iframe_url_as_param="remote" is also set before the ai_external.js as this example works independent of all other examples.
  • add_iframe_url_as_param_prefix="www.mdempfle.de/examples/example33/" - This parameter is a prefix that is added internally to all urls that had this prefix before. This makes the parameter much shorter compared to example 32. Please note that the prefix has to be without the protocol like http://. This is added internally!

Click on the links in the iframe and check the URL in the address bar. Also reload the page when you are on a different page. The current page in the iframe should be opened again.

Additionally the feature "Use iframe title for parent" is enabled. For the remote domain the setting to use is var use_iframe_title_for_parent="remote"; If you additionally set this directly in the administration then the normal title is replaced with a space until the title from the iframe is available. This is not enabled in this demo as the generation of the title is before the the evaluation of shortcodes and this would also affect other demos otherwise. So if you enable this in the administration you need to enable this for all of your iframes!

[advanced_iframe securitykey="your key" src="//www.mdempfle.de/examples/example33/page1.html" use_shortcode_attributes_only="true" id="example33" height="150" width="310" map_parameter_to_url="page"  add_iframe_url_as_param="remote" add_iframe_url_as_param_prefix="www.mdempfle.de/examples/example33/"]

On the remote page you have to add
<script>
var updateIframeHeight = "true";
var iframe_id = "example33";
var add_iframe_url_as_param="remote";
var use_iframe_title_for_parent="remote";
</script>
<script src="//www.tinywebgallery.com/blog/wp-content/plugins/advanced-iframe/js/ai_external.js"></script>