Creating a Dynamic Embedded Confluence Browser on Another Confluence Page

Tim Borrelli February 23, 2015

Hey all!

I was wondering if it was possible to create a field on any Confluence page that acted like an embedded browser, where that field's content was dynamically loaded based on a link clicked on the Confluence page.

I know you can embed static Confluence pages into other pages, but I can't find anything on how to do it dynamically based on a link click.

Thanks!

Tim

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Tim Borrelli February 25, 2015

That's exactly what I want to do. I have a link on my main page, and clicking it loads the page for that link in a section on the main page.

Jody Glover April 18, 2017

Tim, I'd be interested in seeing your code solution, if possible.

0 votes
Jonathan Simonoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2015

You can do this using AJAX.  Here's a user macro that does that for a different purpose (asynchrounously executing an include of a page that takes a long time to render).  You should be able to extract what you need from this.

## Macro title: Asyncronous Include
## Macro has a body: Y 
## Body processing: unrendered
## Output: Selected output option
##
## Developed by: Jonathan Simonoff
## Date created: 12/30/2013
## Installed by: Jonathan
## Renders and inserts content of named page using ajax.
## @param page:title=Included Page Name|type=confluence-content|required=true|desc=The page to be included.
## Param could contain space, or not
#set($random=$content.currentDate.getTime())
#set($colonlocation=$parampage.indexOf(":"))
#if($colonlocation>-1)
 #set($mypage=$parampage.substring($colonlocation))
 #set($myspace=$parampage.substring(0,$colonlocation))
 #set($mypage=$mypage.replace(":",""))
#else
 #set($mypage=$parampage)
 #set($myspace=$space.getKey())
#end
<div id="deferreddiv${random}" class="deferreddiv">
</div>
<script>
  var deferrediv=document.getElementById("deferreddiv${random}")
  deferreddiv${random}.innerHTML="${body}"
  jQuery.ajax({
    type: "POST",
    timeout: 300000,
    url : "/rpc/json-rpc/confluenceservice-v2/renderContent",
    data: ' [ "ASPACEKEY", 76281481, "{include:${myspace}:${mypage}}" ] ',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success : function(result){
        deferreddiv${random}.innerHTML=result.replace("<p></p>","").replace("<p></p>","");
    },
    failure: function(errMsg){
        alert(errMsg);
    },
    error: function(xhr, ajaxOptions, thrownError){
        alert("Error.  Reason: " + thrownError);
    }
  });
</script>
Tim Borrelli February 25, 2015

I will try this out. Thank you!

Jody Glover April 18, 2017

I would like to be able to include a Confluence page in another Confluence  page (same Confluence instance) dynamically. I don't think the Include Macro is going to work in this case as I don't understand how to make the page name variable. 

I'm wondering if Jonathon's macro script could be Javascript only and included in a page via the HTML macro? I've tried, but no luck yet. Hoping someone will help.

I essentially want to create a slide show using the pages in the space.

0 votes
Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2015

So, you want to be able to click something, and load a different page inside a section? Can you more plainly explain the use-case?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events