NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      Some JavaScripts are not successfully executed if included in User Macro, whether or not the JS is included in .js file or is included directly into the macro template between <script></script> tags.

      Steps to reproduce

      1. Download the attached jquery.zrssfeed.min.js file and put it into <confluence-install>/confluence folder
      2. Create a new user macro
      3. Add the following user macro template and change <confluence-url> below into your Confluence Access URL:
        ## @param URL:title=URL|type=string|required=true|desc=The URL of the RSS Feed
        
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"></script>
        <script src="http://<confluence-url>/jquery.zrssfeed.min.js" type="text/javascript"></script>
        
        <div id="feedtarget"></div>
        
        <script type="text/javascript">
        AJS.$(document).ready(function () {
          $('#feedtarget').rssfeed('$paramURL', {
            limit: 5
          });
        });
        </script>
        
      4. Create a new page
      5. Insert the newly created macro and add this URL feed into the macro settings: http://feeds.bbci.co.uk/news/rss.xml
      6. Save the page

      Nothing is shown in the page. Note that this was previously working in Confluence 3.5.13.

      Workaround 1
      Insert a HTML macro (make sure to enable the plugin module first) and add the following codes: (and delete these codes from the User Macro)

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"></script>
      <script src="http://<confluence-url>/jquery.zrssfeed.min.js" type="text/javascript"></script>
      

      Workaround 2
      Insert the code above into Custom HTML (At end of the HEAD). Don't forget to delete these codes from the User Macro.

        1. Invalid HTML.jpg
          Invalid HTML.jpg
          82 kB
        2. jquery.zrssfeed.min.js
          3 kB

            [CONFSERVER-26104] Some JavaScripts are not executed if included in User Macro

            Caterina Trainito added a comment - - edited

            Simon's solution for the issue collector macro worked for us on Confluence 7.20. Thank you!

            Caterina Trainito added a comment - - edited Simon's solution for the issue collector macro worked for us on Confluence 7.20. Thank you!

            Kernebone added a comment -

            Thanks Simon. That fixed my problem.

            Kernebone added a comment - Thanks Simon. That fixed my problem.

            This issue gets mentioned for quite some time now, on the 'Advanced use of the Jira Issue Collector' Docu page.

            While I can confirm, that the Issue Collector does not work if pasted into a user macro as-is,
            I also find that it does work, as soon as I put the script-closing-tag (</script>) on a new line in the user macro source.

            In the above example, that would correspond to instead writing

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript">
            </script>
            <script src="http://<confluence-url>/jquery.zrssfeed.min.js" type="text/javascript">
            </script>
            

            We are on Confluence 7.3.3, but I believe this used to work in earlier versions as well, in this manner.
            Can someone confirm?

            Simon Tost [TNG] added a comment - This issue gets mentioned for quite some time now, on the 'Advanced use of the Jira Issue Collector' Docu page. While I can confirm, that the Issue Collector does not work if pasted into a user macro as-is, I also find that it does work, as soon as I put the script-closing-tag ( </script> ) on a new line in the user macro source. In the above example, that would correspond to instead writing <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"> </script> <script src="http://<confluence-url>/jquery.zrssfeed.min.js" type="text/javascript"> </script> We are on Confluence 7.3.3, but I believe this used to work in earlier versions as well, in this manner. Can someone confirm?

            Almost 6 years later ... Confluence Server 6.6.2 here.

            Luís GÓIS added a comment - Almost 6 years later ... Confluence Server 6.6.2 here.

            Pretty major impediment on our end. Having to embed the issue collector using html means more code exposed to end users and more to potentially break.

            Ameen Belbahri added a comment - Pretty major impediment on our end. Having to embed the issue collector using html means more code exposed to end users and more to potentially break.

            +1 - a fix for this would be very helpful.

            Mark Stramaglia added a comment - +1 - a fix for this would be very helpful.

            I need this as well.

            Ismar Slomic added a comment - I need this as well.

            Need this

            Ben Arundel added a comment - Need this

            Any progress here? Seems to be a tiny fix that is needed here and could help quite much in integrating JIRA into our Intranet.

            Cedric Weber added a comment - Any progress here? Seems to be a tiny fix that is needed here and could help quite much in integrating JIRA into our Intranet.

            I totally agree with Jansen Davis! And it is a shame that a) it is deemed a minor bug and b) that has been assigned for one and a half year Atlassian markets its products with emphasis on working together - and this bug is at the core of the marketing idea and should be fixed - or even better, a much more elegant integration for JIRA issue collector is implemented, something where we do not need to code even a user macro

            BTW, how does workaround #2 work with the new standard design theme? Do I have to edit the "main site layout"? Maybe this can be updated here.

            Does not seem to work on 5.3, either, but did no extensive checking yet.

            Peter Scheidt added a comment - I totally agree with Jansen Davis! And it is a shame that a) it is deemed a minor bug and b) that has been assigned for one and a half year Atlassian markets its products with emphasis on working together - and this bug is at the core of the marketing idea and should be fixed - or even better, a much more elegant integration for JIRA issue collector is implemented, something where we do not need to code even a user macro BTW, how does workaround #2 work with the new standard design theme? Do I have to edit the "main site layout"? Maybe this can be updated here. Does not seem to work on 5.3, either, but did no extensive checking yet.

            I appreciate all the suggested workarounds regarding using js macros and html macros; however, they appear specific to the Enterprise version of JIRA and not OnDemand.

            Are there any known OnDemand resolutions or workarounds for using a JIRA Issue Collector within Confluence? I, for one, was very disappointed and shocked to discover that even though it is documented as being an OnDemand feature and there are many OnDemand-related Help topics and articles\posts describing how to use it, IT DOES NOT WORK and there is no way to get it to work. Our team has a very real need to keep our JIRA admin features and licensed seats separate from our Confluence collaboration users and number of seats; however, we have an equivalent need to allow our Confluence users to be able to report and view issues using an integrated and standardized mechanism. This feature was one of the main attractions that swayed us to go with Atlassian's solution; however, we feel mislead and if we weren't so far down our critical path and if we hadn't spent weeks "selling" JIRA to our client as being the "best" agile management and collaboration tool for our project we would be switching to something else!

            My common sense says the following:
            1) it is a natural feature that would bridge issue reporting and feedback between the two products,
            2) it is a natural mechanism for compartmentalizing security between users\admins while enabling non-JIRA issue reporting,
            3) it either was a blatant oversight by designers\developers (we've all been guilty on this one) or it was a planned crippling of an extremely useful feature in order to upsale OnDemand customers to the Enterprise version or to enhance support agreements.

            Just my opinion FWIW!

            Jansen Davis added a comment - I appreciate all the suggested workarounds regarding using js macros and html macros; however, they appear specific to the Enterprise version of JIRA and not OnDemand. Are there any known OnDemand resolutions or workarounds for using a JIRA Issue Collector within Confluence? I, for one, was very disappointed and shocked to discover that even though it is documented as being an OnDemand feature and there are many OnDemand-related Help topics and articles\posts describing how to use it, IT DOES NOT WORK and there is no way to get it to work. Our team has a very real need to keep our JIRA admin features and licensed seats separate from our Confluence collaboration users and number of seats; however, we have an equivalent need to allow our Confluence users to be able to report and view issues using an integrated and standardized mechanism. This feature was one of the main attractions that swayed us to go with Atlassian's solution; however, we feel mislead and if we weren't so far down our critical path and if we hadn't spent weeks "selling" JIRA to our client as being the "best" agile management and collaboration tool for our project we would be switching to something else! My common sense says the following: 1) it is a natural feature that would bridge issue reporting and feedback between the two products, 2) it is a natural mechanism for compartmentalizing security between users\admins while enabling non-JIRA issue reporting, 3) it either was a blatant oversight by designers\developers (we've all been guilty on this one) or it was a planned crippling of an extremely useful feature in order to upsale OnDemand customers to the Enterprise version or to enhance support agreements. Just my opinion FWIW!

            You can add 5.2.3 to the affected versions.
            -David

            Intel CHD Jira Admin added a comment - You can add 5.2.3 to the affected versions. -David

            Matt Michal added a comment - - edited

            Any updates on this? I'm facing this issue when creating a user macro in Confluence 5.1.

            Matt Michal added a comment - - edited Any updates on this? I'm facing this issue when creating a user macro in Confluence 5.1.

            The consequence of this is that it is impossible to package the Jira issue collector in a user macro. (See https://jira.atlassian.com/browse/CONF-26104.)

            Here is what the code generated by the issue collector looks like after it has been rendered as HTML by a user macro:

            <script type="text/javascript">//<![CDATA[
            
            window.ATL_JQ_PAGE_PROPS = .extend(window, {
                "triggerFunction": function(showCollectorDialog) {
                    jQuery("#callcollector").click(function(e) {
                        e.preventDefault();
                        showCollectorDialog();
                    });
                },
            	fieldValues: {
            	}
            });
            
            //]]>
            

            Compare this to the HTML generated from the HTML macro (which works):

            <script type="text/javascript">
            window.ATL_JQ_PAGE_PROPS = $.extend(window.ATL_JQ_PAGE_PROPS, {
                "triggerFunction": function(showCollectorDialog) {
                    jQuery("#callcollector").click(function(e) {
                        e.preventDefault();
                        showCollectorDialog();
                    });
                },
                fieldValues: {
                }
            });
            </script>
            

            It looks like the CDATA bracketing isn't a good idea.

            The Jira guys evidently think this is a breeze: "The Issue Collector can be embedded into Confluence using a User Macro..." (https://confluence.atlassian.com/x/2AKmEQ). Have they been told this doesn't work anymore?

            Regards,
            David

            Intel CHD Jira Admin added a comment - The consequence of this is that it is impossible to package the Jira issue collector in a user macro. (See https://jira.atlassian.com/browse/CONF-26104 .) Here is what the code generated by the issue collector looks like after it has been rendered as HTML by a user macro: <script type="text/javascript">//<![CDATA[ window.ATL_JQ_PAGE_PROPS = .extend(window, { "triggerFunction": function(showCollectorDialog) { jQuery("#callcollector").click(function(e) { e.preventDefault(); showCollectorDialog(); }); }, fieldValues: { } }); //]]> Compare this to the HTML generated from the HTML macro (which works): <script type="text/javascript"> window.ATL_JQ_PAGE_PROPS = $.extend(window.ATL_JQ_PAGE_PROPS, { "triggerFunction": function(showCollectorDialog) { jQuery("#callcollector").click(function(e) { e.preventDefault(); showCollectorDialog(); }); }, fieldValues: { } }); </script> It looks like the CDATA bracketing isn't a good idea . The Jira guys evidently think this is a breeze: "The Issue Collector can be embedded into Confluence using a User Macro..." ( https://confluence.atlassian.com/x/2AKmEQ ). Have they been told this doesn't work anymore? Regards, David

            Confluence is dropping the </script> tag which is producing invalid HTML. The attached screenshot shows how Chrome interprets the resulting INVALID HTML.

            This is still a problem in Confluence 4.2.11

            Broadcom Support added a comment - Confluence is dropping the </script> tag which is producing invalid HTML. The attached screenshot shows how Chrome interprets the resulting INVALID HTML. This is still a problem in Confluence 4.2.11

            The Confluence renderer is taking this:

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"></script>

            and turning it into this:

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript" />

            This XHTML syntax is unsupported in the browser, so the browser treats it as and unclosed script tag.

            I have a very basic {javascript} macro that is suffering from this problem:

            ## @param URL:title=Script URL|type=string|desc=Only populate this field if you are importing an external script.|required=false
            #if ($paramURL && $paramURL.length() > 0)
            <script type="text/javascript" src="$!paramURL"></script>
            #elseif ($param0 && $param0.length() > 0)
            <script type="text/javascript" src="$!param0"></script>
            #else
            <script type="text/javascript">
            $body
            </script>
            #end
            

            All of the pages that use this are broken due to this improper mangling of the HTML.

            The workaround is to put a space in between the script open and close tags, like this:

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"> </script>

            Broadcom Support added a comment - The Confluence renderer is taking this: <script src= "https: //ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type= "text/javascript" ></script> and turning it into this: <script src= "https: //ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type= "text/javascript" /> This XHTML syntax is unsupported in the browser, so the browser treats it as and unclosed script tag. I have a very basic {javascript} macro that is suffering from this problem: ## @param URL:title=Script URL|type=string|desc=Only populate this field if you are importing an external script.|required= false # if ($paramURL && $paramURL.length() > 0) <script type= "text/javascript" src= "$!paramURL" ></script> #elseif ($param0 && $param0.length() > 0) <script type= "text/javascript" src= "$!param0" ></script> # else <script type= "text/javascript" > $body </script> #end All of the pages that use this are broken due to this improper mangling of the HTML. The workaround is to put a space in between the script open and close tags, like this: <script src= "https: //ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type= "text/javascript" > </script>

              Unassigned Unassigned
              asanusi AmaliaA
              Affected customers:
              87 This affects my team
              Watchers:
              63 Start watching this issue

                Created:
                Updated: