With this feature you can add the current URL of the iframe to the parent. This enables bookmarkable URLs where you go directly to the last page in the iframe. So if someone clicks inside the iframe the new URL is added as parameter to the parent URL and if you use this URL the page in the iframe is not the default one but the one from the parameter. The history API which enables the change of the URL is only supported by modern browsers. For older browsers the URL is simply not changed. See http://caniuse.com/#search=pushstate.
There are 6 different ways to use this feature:
- Example 32: Add the URL on the same domain
- Example 33: Add the URL on the remote domain. This example also shows the feature "Prefix for iframe URL" which does reduce the length of the parameter value.
- Example 56: Add iframe URL as param: Same domain with hash
- Example 57: Add iframe URL as param remote domain with hash + URL rewrite
- New 2021: Example 59: Add iframe params to parent: Same domain
- New 2021: Example 60: Add iframe params to parent: Remote domain
Examples how the URL does look like for the different possible ways:
- Example 32 - The full URL is attached as parameter: ?iframe=www.tinywebgallery.com/blog/e33/page2.html
- Example 33 - The part that is different only is attached as parameter: ?iframe=www.tinywebgallery.com/blog/e33/page2.html
- Example 56 - The URL is saved on the server and only a key of is is attached to the url: ?iframe=A3
- Example 57 - The URL is saved on the server and the key is part of the URL: /iframe/A3
- Example 59/60: Only the parameters of the iframe is attached to the parent and added internally to the iframe URL again: ?param1=1
Which one to pick?
- Go for example 32 if you like a readable URL where no parameters are attached as the would get URL encoded.
- Go for example 33 if you have a common prefix that makes the URL quite short.
- Go for example 56 or 56 if you have many long and different URLs and it is not important that they are readable but you like a short URL
- Go for 59/60 if the changing part is all in the query. It makes the URL in the parent look almost the same as in the iframe.