?? How random should it be? For example could it be inserted in between the letters of a single word? Or should the image overlay whatever already exists on the page?
I think you need to define what you are trying to do a lot better.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Still didn't answer the question: Does the image push other content out of the way and insert itself into the page? For example, if your page was showing
Code:
This is a comment.
Would you want it to change to
Code:
This is a co[IMAGE HERE]mment.
Or do you simply want the image to appear *OVER* some random spot on the page?
"OVER" is trivial. Inserting is tougher.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
function generare()
{
var xmin=0;
var xmax=window.innerWidth;
var ymin=0;
var ymax=window.innerHeight;
var xcoord=Math.floor((Math.random()*xmax)+xmin);
var ycoord=Math.floor((Math.random()*ymax)+ymin);
var pui=document.createElement("img");
pui.setAttribute('src','pisoi.png');
pui.setAttribute('alt','pisoi');
pui.setAttribute('id','pisoi');
pui.style.left=xcoord+'px'
pui.style.top=ycoord+'px';
var pui2=pui.cloneNode(true);
var v=document.getElementsByTagName('body');
for (var i=0; i<3; i++)
{
xcoord=Math.floor((Math.random()*xmax)+xmin);
ycoord=Math.floor((Math.random()*ymax)+ymin);
v[i].appendChild(pui2);
pui2=pui.cloneNode(true);
pui2.style.left=xcoord+'px'
pui2.style.top=ycoord+'px';
}
}
What i want to do is generate this image duplicated several times, on random positions on the screen, but this function generates the image only once.