Advanced Search

Results 1 to 2 of 2

Thread: How do I insert Images in the code below

  1. #1
    Join Date
    Sep 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do I insert Images in the code below

    Code:
    <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....
    Last edited by jscheuer1; 10-27-2010 at 05:07 PM. Reason: format code

  2. #2
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    110
    Thanks
    15
    Thanked 1 Time in 1 Post

    Default

    You can try something like this

    Code:
    <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>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •