Add iframe params to parent: Same domain

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

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

Example 59: Add iframe params to parent: Same domain

This example shows how the current iframe parameters are added to the parent url as parameter if the iframe is on the SAME domain. This features is only available in the pro version of the advanced iframe.

This solution this is another version of the "Add iframe url to parent". The difference to the existing solutions is that only the parameters are added to the parent url. To make it work, you also have to use placeholders in the url or the "Forward params to iframe" feature. The advantage of this solution is that the parent url and the iframe url look quite the same. In the other solutions you either have the full iframe url + params, a short iframe url + params, a hash or a url rewrite with the hash.

So if your iframe url ist e.g. then your parent url will look like

You can enable this for the same domain by adding
add_iframe_url_as_param="same" add_iframe_url_as_param_direct="true"

If someone would now refresh the parent the parent has the parameters needed. To forward them now to the iframe you have 2 options:

  • Forward params to iframe: You have to add url_forward_parameter to your shortcode with url_forward_parameter="ALL" or if you like to be more restrictive: url_forward_parameter="mypage,mylevel" - This way is shown on this page.
  • Use placeholders the the iframe url: src="{query-mypage}&mylevel={query-mylevel}" - this way is shown in example 60 -> Add iframe params to parent: remote domain

Please check that your parameters are not used by WordPress itself. See here.

Click on the different links in the iframe and check the url in the address bar. Also reload the page when you are on a different page. The demo page prints the url of the iframe so you can easier see what is going on. The 3 links have all different parameters.

Important: The feature only works if you don't have any other query parameters as they are all replaced! If you need other parameters as well please pick one of the other solutions. Also it does not work in the preview of WordPress as there the page_id and the preview parameter is used. Publish the page and test it there.

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.

This is the shortcode for this:
[advanced_iframe securitykey="your key" src="//" use_shortcode_attributes_only="true" id="example59" height="170" width="100%"  add_iframe_url_as_param="same" add_iframe_url_as_param_direct="true" url_forward_parameter="mypage,mylevel"]