PDA

View Full Version : How do I insert Images in the code below



dogstail
10-27-2010, 04:20 PM
<script type="text/javascript">
document.write("<html><head><title>wow i'm good</title></head><body>");
function makeDiv()
{

var r = Math.floor(Math.random()*256);
var g = Math.floor(Math.random()*256);
var b = Math.floor(Math.random()*256);
var wh = 25 + Math.floor(Math.random()*444);
var lr = (Math.random()<.5) ? "top":"right";
var bw = 1 + Math.floor(Math.random()*12);
var bs = (Math.random()<.5) ? " solid":"dotted";
var dc = (Math.random()<.5) ? "Dog" : "Cat";

document.write("<div style=\"float: "+lr+";"+
"width: "+wh+"px;"+
"height: "+wh+"px;"+
"border: rgb(" + g + "," + b + "," + r + ") "+bw+"px "+bs+";"+
"background-color: rgb(" + r + "," + g + "," + b + ");"+
"\">"+dc+
"</div>");

}

var i;
var count = Math.floor(Math.random()*100) + 5;
for (i=0; i<count; i++)
makeDiv();

document.write("</body></html>");

</script>

can you please tell me how can I make the pictures look in different shapes after they are inserted....

sniperman
10-31-2010, 10:46 AM
You can try something like this


<script type="text/javascript">
document.write("<html><head><title>wow i'm good</title></head><body>");
function makeDiv()
{

var r = Math.floor(Math.random()*256);
var g = Math.floor(Math.random()*256);
var b = Math.floor(Math.random()*256);
var wh = 25 + Math.floor(Math.random()*444);
var lr = (Math.random()<.5) ? "top":"right";
var bw = 1 + Math.floor(Math.random()*12);
var bs = (Math.random()<.5) ? " solid":"dotted";
var dc = (Math.random()<.5) ? "<img src='hello.jpg' alt='Dog'>" : "<img src='hello.jpg' alt='Cat' >";

document.write("<div style=\"float: "+lr+";"+
"width: "+wh+"px;"+
"height: "+wh+"px;"+
"border: rgb(" + g + "," + b + "," + r + ") "+bw+"px "+bs+";"+
"background-color: rgb(" + r + "," + g + "," + b + ");"+
"\">"+dc+
"</div>");

}

var i;
var count = Math.floor(Math.random()*100) + 5;
for (i=0; i<count; i++)
makeDiv();

document.write("</body></html>");

</script>