Hi,
My use case;
Each time a document is opened display a random image from a index of 25
The images are located on a external website
I've tried the following
step 0:
I've a document Sandbox.Try
step 1:
I've added a object of type XWiki.JavaScriptExtension to the page
in name: random-header.js
in Code:
// JavaScript Document
images = new Array(25);
images[0] = '<img
src="http://www.cdlsusa.org/images/interiors/1.jpg"
>'
images[1] = '<img
src="http://www.cdlsusa.org/images/interiors/2.jpg"
>'
images[2] = '<img
src="http://www.cdlsusa.org/images/interiors/3.jpg"
>'
images[3] = '<img
src="http://www.cdlsusa.org/images/interiors/4.jpg"
>'
images[4] = '<img
src="http://www.cdlsusa.org/images/interiors/5.jpg"
>'
images[5] = '<img
src="http://www.cdlsusa.org/images/interiors/6.jpg"
>'
images[6] = '<img
src="http://www.cdlsusa.org/images/interiors/7.jpg"
>'
images[7] = '<img
src="http://www.cdlsusa.org/images/interiors/8.jpg"
>'
images[8] = '<img
src="http://www.cdlsusa.org/images/interiors/9.jpg"
>'
images[9] = '<img
src="http://www.cdlsusa.org/images/interiors/10.jpg"
>'
images[10] = '<img
src="http://www.cdlsusa.org/images/interiors/11.jpg"
>'
images[11] = '<img
src="http://www.cdlsusa.org/images/interiors/12.jpg"
>'
images[12] = '<img
src="http://www.cdlsusa.org/images/interiors/13.jpg"
>'
images[13] = '<img
src="http://www.cdlsusa.org/images/interiors/14.jpg"
>'
images[14] = '<img
src="http://www.cdlsusa.org/images/interiors/15.jpg"
>'
images[15] = '<img
src="http://www.cdlsusa.org/images/interiors/16.jpg"
>'
images[16] = '<img
src="http://www.cdlsusa.org/images/interiors/17.jpg"
>'
images[17] = '<img
src="http://www.cdlsusa.org/images/interiors/18.jpg"
>'
images[18] = '<img
src="http://www.cdlsusa.org/images/interiors/19.jpg"
>'
images[19] = '<img
src="http://www.cdlsusa.org/images/interiors/20.jpg"
>'
images[20] = '<img
src="http://www.cdlsusa.org/images/interiors/21.jpg"
>'
images[21] = '<img
src="http://www.cdlsusa.org/images/interiors/22.jpg"
>'
images[22] = '<img
src="http://www.cdlsusa.org/images/interiors/23.jpg"
>'
images[23] = '<img
src="http://www.cdlsusa.org/images/interiors/24.jpg"
>'
images[24] = '<img
src="http://www.cdlsusa.org/images/interiors/25.jpg"
>'
images[25] = '<img
src="http://www.cdlsusa.org/images/interiors/26.jpg"
>'
index = Math.floor(Math.random() * images.length);
in use this extension: on demand
parse content: no
caching policy: long
step 2
In the page i've added the following
{{velocity}}
$xwiki.jsx.use('Sandbox.Try')
{{/velocity}}
{{html wiki="false"}}<!-- start main image div & javascript for home page
-->
<div id="interior-pg-main-img">
<div style="float: left;">
<script type="text/javascript">
document.write(images[index]);
</script>
</div>
</div>
<!-- end main image div & javascript for home page -->
{{/html}}
step 3:
Empty page ;-(
Any suggestions how to approach this more effective
Gerritjan