Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Problem with iframe in DIV macro Edited

I am creating a DIV macro that will allow users to place custom <div> tags and place content within the div.

I tested with an iframe and i noticed that there are extraneous tags being displayed as plain text after the iframe.

I'm just basing this test on the "collapse" macro from this page: https://confluence.atlassian.com/conf73/writing-user-macros-991928530.html

screenshot_2020-11-12_08.33.13_img.png

I'm putting the HTML macro with my iframe within my DIV macro.

screenshot_2020-11-12_08.32.09_img.pngThis is what the rendered page looks like.  The iframe is correctly inside my div container, but there is an extra "</div>" printed after the iframe

screenshot_2020-11-12_08.32.27_img.png

 

Looking at the page source, the </div> is both in the html as expected but also in some text after the iframe.

screenshot_2020-11-12_08.37.02_img.png

This becomes even more of a problem if you have nested div macros or tables, it seems to print out any closing tags after the iframe.

 

I've tested with a few other websites in the iframe with similar results.

1 answer

1 accepted

0 votes
Answer accepted

Why are you nesting a HTML macro inside the body of the macro? I would just structure the macro so that all the HTML is inside the user macro, and then you can either have body hold the src link, or even make it a parameter with no macro body. Then use the parameters in your code.

I would also make the width and height parameters to make it more configurable.

 

If you need the HTML macro, then move that instance to inside the user macro. Take a look at this article I wrote awhile back on wrapping a macro: Getting Started with User Macros - Writing a Wrapper Macro 

Thanks for the info Bill, I'll take a look at your article.

The original intent was to have a generic div macro that could include any content like text or other macros.  This would help tie in with custom stylesheets and being able to style elements with a surrounding div id/class.

Are there known issues with nested macros?

Bill Bailey Community Leader Nov 17, 2020

I think the issue with nested macros is unpredictability with the rendered output. I have always gone the route or wrapping a macro if needed.

I see.  Yeah I've been trying to generalize macros as best i can and then nest any existing macros inside, but like you said I've also ran into some strange cases of the output not behaving as expected.

I'll try making a simple iframe specific macro and see if that has any similar issues.

For the most part, I haven't had issues with the nested div macros in my post.  But seems to be something with how the iframe is processed in conjunction with the macro.

Putting the iframe directly in the macro (not using the nested html macro):

<div><iframe>...</iframe></div>  still has the issue

 

Putting just the iframe in the macro seems to work fine.

I will just create an iframe macro and expose some paramters.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

146 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you