问题
I have a problem running javascripts from trac. I know there are security issues around this, but my trac installation is only used as an intranet.
I have got the following code to work (requires setting rendering_unsafe_content = true under [wiki] in trac.ini):
{{{
#!html
<script type="text/javascript" >
document.write("This is a test")
</script>
}}}
However, replacing this with the javascript in a seperate file will fail:
{{{
#!html
<script type="text/javascript" src="/tracproject/htdocs/test.js" >
</script>
}}}
where tracproject is the root folder of trac and test.js contains document.write("This is a test").
Any clues?
回答1:
Have you tried the 'Add Headers Plugin' (http://trac-hacks.org/wiki/AddHeadersPlugin) ? It looks like it allows you to do include custom javascript like you want but in a more straightforward way than having to modify templates directly.
回答2:
The option is [wiki] render_unsafe_content
(see documentation). You can reference the file in your site htdocs directory on the path /tracproject/chrome/site/test.js
. I tried your example just now and it work correctly once the src
path is changed.
See the TracInterfaceCustomization page for more details.
来源:https://stackoverflow.com/questions/4580827/referencing-javascript-from-trac-wiki