Hi there,
Is it possible to add a javascript function in the announcement banner?
I'd like to add a function that show a dialog box before exit browser.
(My goal is to "force" users log daily work on issues)
Thanks
Hi Fulvio,
sorry but on the cloud JIRA you can't add javascript to the announcement banner.
You can not put in place this requirement.
Ciao,Fabio
you can do that. You need just to add tag script within annoncement
<script>jQuery().ready(function() {....<YOUR CODE HERE>....});</script>
Hope this helps,
Fabio
Thanks Fabio,
is this code going to work properly?
<span><script><br></span><span>jQuery().ready(function(){ window</span><span>.</span><span>onbeforeunload </span><span>=</span> <span>function</span> <span>(</span><span>e</span><span>)</span> <span>{</span><span> e </span><span>=</span><span> e </span><span>||</span><span> window</span><span>.</span><span>event</span><span>;</span> <span>// For IE and Firefox prior to version 4</span> <span>if</span> <span>(</span><span>e</span><span>)</span> <span>{</span><span> e</span><span>.</span><span>returnValue </span><span>=</span> <span>'Sure?'</span><span>;</span> <span>}</span> <span>// For Safari</span> <span>return</span> <span>'Sure?'</span><span>;</span> <span>};<br></span>}); <span></script></span>
Maybe I should format the dialog in Jira style
did u test it?
Hi Fabio,
not yet, I'm goin' to test it in a couple of hours
Hmm, I've tried it with this code:
<span><script><br></span><span>jQuery().ready(function(){ window</span><span>.</span><span>onbeforeunload </span><span>=</span> <span>function</span> <span>(</span><span>e</span><span>)</span> <span>{</span><span> e </span><span>=</span><span> e </span><span>||</span><span> window</span><span>.</span><span>event</span><span>;</span> <span>// For IE and Firefox prior to version 4</span> <span>if</span> <span>(</span><span>e</span><span>)</span> <span>{</span><span> e</span><span>.</span><span>returnValue </span><span>=</span> <span>'Sure?'</span><span>;</span> <span>}</span> <span>// For Safari</span> <span>return</span> <span>'Sure?'</span><span>;</span> <span>};<br></span><span>});</span><span></script></span>
but it shows the entire code
if you try this code you can figure out that this approach works
<script>alert("Script works");</script>
I had not chance to test your script
Ciao,
I've tried the code you've posted, but I can still see the entire code
It seems javascript's not working properly on my Jira Cloud
That's too bad
Thanks for the help anyway
There are a lot of limitation using JIRA Cloud.
You're welcome,
Hi Fabio, 3 years later, is there any way for admins to include custom javascript in Jira Cloud, as you can in server? Is there any policy against add-ins that might allow this? I really think it should be at the organizations discretion to customize the UI this way, and not having that ability will make migration a challenge.
Hi @Chris M_ ,
unfortunately you can't do that.
√
In Jira Cloud it seems they've decided to htmlencode the whole banner string so that html is not parsed by the browser. They could allow this by omitting this step, instead we'll have to wait until automation add-in vendors get a stable version of the UI toolkit so we can emulate some of the functions we need. Really I'd like to see a system option that allows html & js in the banner instead, even if it is "at your own risk."
It looks like you're new here. Sign in or register to get started.