Iframe Navigation Macro
Last modified by Thomas Mortagne on 2026/02/26 15:46
| Allows you to add an iframe in the content of a page with links to change the website displayed in the iframe. |
| Type | Doc (Velocity Macro) |
| Category | |
| Developed by | xwiki:XWiki.ThomasEveilleau |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Allows you to add an iframe in the content of a page with links to change the website displayed in the iframe (its an Iframe+ Macro)
Usage
#iframelink("URL" "Iframe Name" "Text displayed")
#iframelink("URL" "Iframe Name" "Text displayed")
#iframebox("Iframe Name" "Width" "Height")Parameters definition
For the #iframelink Macro
| Name | Optional | Allowed values | Default value | Description |
|---|---|---|---|---|
| URL | no | string | none | URL of the website you want to display in your iframe |
| Iframe Name | yes | string | iframe | Name of the iframe you want to target |
| Text Displayed | yes | string | link | Text displayed for the link |
For the #iframebox Macro
| Name | Optional | Allowed values | Default value | Description |
|---|---|---|---|---|
| Iframe Name | yes | string | iframe | Name of the Iframe |
| Width | yes | int +px or percentage +% | 100% | Width of the iframe |
| Height | yes | int +px | 500px | Height of the iframe |
Example
* #iframelink("http://www.google.fr" "" "Google")
* #iframelink("http://www.yahoo.fr" "" "Yahoo")
----
#iframebox("" "100%" "500")Result

Installation
This a Velocity macro. Since it's not bundled by default you'll have to copy/paste the following code to use it:
#macro(iframelink $url $target $text)
#if($target=="")
#set($target="iframe")
#end
#if($text=="")
#set($text="link")
#end
<a href="${url}" title="iframelink" target="${target}">${text}</a>
#end
#macro(iframebox $name $width $height)
#if($name=="")
#set($name = "iframe")
#end
#if($width=="")
#set($width="100%")
#end
#if($height=="")
#set($height="500px")
#end
<iframe name="${name}" width="${width}" height="${height}"></iframe>
#end