Javascript works in announcement banner but not when in web resource module.

Hi All ,

I need to execute a javascript using web resource plugin module the same way it gets executed when i paste it in the announcement banner .

below is the xml

<web-resource key="my js" name="my js" >
        <resource type="download" name="test.js" location="/templates/test.js" />

can someone please help me with this ??

The script does not get executed and is not even seen in the page source ... how can i make this script work ?

2 answers

1 accepted

1 vote
Accepted answer

I think the problem is leading slash in location it should be templates/test.js

Hi Vishwajeet,

Even after removing the slash the script does not get executed.

0 votes

Are you using WebresourceManager to make sure the resources are loaded?


I am not using any .vm files . I have a javascript which redirect to a link when i add a version in JIRA . Now i need to embed this script in a plugin instead of pasting it in the announcement banner .

Do i need to include a .vm file as resource?

My plugin key has a space eg: my plugin , can this be a reason ?

@Jobin : you don't need this in scenario he has mentioned, once he set the context to jira.general it should be available on all pages irrespective of required resource statement

@Mizan : I suspected the space but I thought that's just an example, I haven't scene any code with space in key, you can quickly try removing the same.

@Vishwa Ah, I see what you mean. Thought he is trying to get it in some plugin templates.

@Vishwajeet: tried removing the space from the key but still script does not work.

now i can see the script in the page source as below

<script type="text/javascript" src="/jira/s/en_US-tp7cj4/768/3/1.0-SNAPSHOT/_/download/resources/com.mizan.jscripts.jscripts:test/test.js" ></script>

the script is a simple alert however it is not working . its works when pasted in the anouncement banner .

Is there something else i need to specify in the script since Jira version is 5.1.8 ?

The script works now , i was not removing the javascript tags from the js file . after remving it it works ...

Thank you Jobin and Vishwajeet for your support .

I will select Vishwajeets answer first becoz Jobin already has a lot of karma ;)

Hi ,

The original script does not work only alert statement worked .

                if(AJS.$(this).html() =='Merge'){
AJS.$(document.body).on('submit', 'form', function(){
var pkey=document.getElementById("project-config-details-project-key").innerHTML;
var burl=AJS.$("input[title='baseURL']").val()

Is there something missing in the above script ?

did you checked pkey and burl getting expecting values ?

Note: if you modified existing js file and added new code? if yes, then you need to restart jira

Yes i get expected values .. the script works when its in announcement banner but not when in web resource plugin.

Even after a restart the script did not work ..

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,725 views 17 21
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you