Results 1 to 5 of 5

Thread: Randomize Text and Image Crawler?

  1. #1
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Randomize Text and Image Crawler?

    1) Script Title: Text and Image Crawler

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...wler/index.htm

    3) Describe problem: I would like to know if there is a way to randomize which image shows up first.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Use this modified version of the crawler.js file named here as crawler_rand.js (right click and choose 'save as'):

    Attachment 3153

    Change this on your page as highlighted:

    Code:
    <script type="text/javascript" src="crawler_rand.js">
    /*
    Text and/or Image Crawler Script ©2009-2010 John Davenport Scheuer
    as first seen in http://www.dynamicdrive.com/forums/ username: jscheuer1
    This Notice Must Remain for Legal Use
    updated: 02/16/2010 for random image order option
    */
    </script>
    Then you may add to your on page init, for example (highlighted):

    Code:
    <script type="text/javascript">
    marqueeInit({
     random: true,
     uniqueid: 'art',
     direction: 'right',
     style: { //style object for this marquee container (use quotes on both sides of the : as shown)
    	'width': '60%',
    	'height': '235px',
    	'background-color': '#ddd',
    	'border': '1px solid #111',
    	'margin': '2ex auto 0 auto'},
     inc: 6, //speed - pixel increment for each iteration of this marquee's movement
     moveatleast: 4,
     mouse: 'cursor driven' //mouseover behavior ('pause' 'cursor driven' or false)
    });
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you John. This definitely randomizes the images. But it also seems to randomize which hyperlink is assigned to which image. Is there anyway to keep the images with their hyper links? Perhaps wrap them in a <div> or something like that?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You said images. No matter. We can make the tag the option, use this version:

    Attachment 3155

    Change this on your page as highlighted (from the last changes):

    Code:
    <script type="text/javascript" src="crawler_rand_2.js">
    /*
    Text and/or Image Crawler Script ©2009-2010 John Davenport Scheuer
    as first seen in http://www.dynamicdrive.com/forums/ username: jscheuer1
    This Notice Must Remain for Legal Use
    updated: 02/18/2010 for random tag order option
    */
    </script>
    Then you may add to your on page init, for example (highlighted):

    Code:
    <script type="text/javascript">
    marqueeInit({
     random: 'a',
     uniqueid: 'art',
     direction: 'right',
     style: { //style object for this marquee container (use quotes on both sides of the : as shown)
    	'width': '60%',
    	'height': '235px',
    	'background-color': '#ddd',
    	'border': '1px solid #111',
    	'margin': '2ex auto 0 auto'},
     inc: 6, //speed - pixel increment for each iteration of this marquee's movement
     moveatleast: 4,
     mouse: 'cursor driven' //mouseover behavior ('pause' 'cursor driven' or false)
    });
    </script>
    That tells it to use the 'a' tags. Since the images are inside those tags, they will be randomized right along with them and retain their relationship to them. It assumes that all of the images are linked. If there were no links, one could specify 'img'. Divisions shouldn't be used in the crawler because they will introduce line breaks. But if you were to have a mixture of linked and non-linked images, one could use span tags, ex:

    HTML Code:
    <span><a href="../files/photo1.jpg"><img src="../files/photo1.jpg" alt=""></a></span> 
    <span><img src="../files/photo2.jpg" alt=""></span>
    and in the init:

    Code:
    marqueeInit({
     random: 'span',
     unique . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thank you!

    Brilliant. Thank you very much. I do have a mix of images with and without links so the span option is perfect. Thank you again.

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
  •