Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Help please ASAP! In desperate need!

    Hi! I am making my bands website, n i though this template would make my vision easy to do..but it hasn't worked out how i'd of liked it to.

    www.penitentiary.co.uk

    I have already put the other half of the script in, but it is this part which is wrong. It is script so that every time the home page is visited, 1 of 6 images appears at random adding variety...however, 4 of the images link to different areas of the site (this is possible?) I guess it's cause i've used HTML coding in it, but i know nothing of java.

    Below is the script..if you could help me based on what I offer you, or even correct it for me, i'd be so appriciative..as i'm pulling my hair out over this.

    ~Blade376



    <script language="JavaScript" type="text/javascript">
    // This script was supplied free by Hypergurl
    // http://www.**************
    <!--
    // JavaScript to interpolate random images into a page.
    var ic = 6; // Number of alternative images
    var xoxo = new Array(ic); // Array to hold filenames

    xoxo[0] = "http://www.penitentiary.co.uk/Home%20Page%20Adverts/13th%20March%20Gig%20Edit.jpg";
    xoxo[1] = "http://www.penitentiary.co.uk/Home%20Page%20Adverts/EPADlarge.jpg";
    xoxo[2] = <p align="center"><a href="http://www.penitentiary.co.uk/EPcoverdesigns.htm"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/epcoverdesignAD.jpg"></a>;
    xoxo[3] = <p align="center"><a href="http://www.penitentiary.co.uk/Flyers.htm"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/FlyersADlarge.jpg"></a>;
    xoxo[4] = <p align="center"><a href="http://www.penitentiary.co.uk/forum/index.php"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/ForumADlarge.jpg"></a>;
    xoxo[5] = <p align="center"><a href="http://www.penitentiary.co.uk/news.htm"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/MailinglistADlarge.jpg"></a>;

    function pickRandom(range) {
    if (Math.random)
    return Math.round(Math.random() * (range-1));
    else {
    var now = new Date();
    return (now.getTime() / 1000) % range;
    }
    }
    // Write out an IMG tag, using a randomly-chosen image name.
    var choice = pickRandom(ic);
    // -->
    </script>

  • #2
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found this, but it says configure images to corresponding links...how do i do that?


    -----------

    <script language="JavaScript">
    <!--

    /*
    Random Image Script- By JavaScript Kit (http://www.javascriptkit.com)
    Over 400+ free JavaScripts here!
    Keep this notice intact please
    */

    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="image1.gif"
    myimages[2]="image2.gif"
    myimages[3]="image3.gif"
    myimages[4]="image4.gif"
    myimages[5]="image5.gif"
    myimages[6]="image6.gif"

    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<img src="'+myimages[ry]+'" border=0>')
    }
    random_imglink()
    //-->
    </script>

    <p align="center"><font face="arial" size="-2">This free script provided by</font><br>
    <font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
    Kit</a></font></p>

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ahhh, one of HyperGirl's stolen and plagiarized scripts....
    No offense, but that script is not worth fixing...

    You can try my Random Image Link script...
    It should be somewhat easier to use and also has the benifit of being reused several times on a page without duplicating any of the image/links...

    To install, simply place the script into the HEAD of your document... Add your images and links by following the examples and where you would like a random image to appear add this script call: <script>randomLink()</script>

    Code:
    <script type="text/javascript">
     var myNumbers = [];
      function randomLink(){ 
       var theLinks = [// ADD YOUR IMAGES AND LINKS BELOW //;
                      [ 'images/image0.jpg' , 'site0.html' ], 
                      [ 'images/image1.jpg' , 'site1.html' ],
                      [ 'images/image2.jpg' , 'site2.html' ],
                      [ 'images/image3.jpg' , 'site3.html' ],
                      [ 'images/image4.jpg' , 'site4.html' ],
                      [ 'images/image5.jpg' , 'site5.html' ],
                      [ 'images/image6.jpg' , 'site6.html' ],
                      [ 'images/image7.jpg' , 'site7.html' ],
                      [ 'images/image8.jpg' , 'site8.html' ],
                      [ 'images/image9.jpg' , 'site9.html' ]
                      ]// NO NEED TO EDIT BELOW THIS LINE //;
    
    
       var theNumber = Math.round(Math.random()*(theLinks.length-1));
        if(myNumbers.length < theLinks.length){
          for(var count=0; count<myNumbers.length; count++){ 
            while(theNumber == myNumbers[count]){
               theNumber = Math.round(Math.random()*(theLinks.length-1));
               count = 0;
            }
          }    myNumbers.push(theNumber);
        } 
    
        else{theNumber = 0};
         var  anchor = '<a class="random" href="'+theLinks[theNumber][1]+'">';
              anchor+= '<img src="'+theLinks[theNumber][0]+'"></a>';
              document.writeln(anchor);
      }
    </script>
    </head>
    
    <body>
    <script>randomLink()</script><br>
    <script>randomLink()</script><br>
    <script>randomLink()</script><br>
    <script>randomLink()</script><br>
    .....Willy

  • #4
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried your code Willi and it worked great in Netscape and Safari, but not in Explorer 5.2.3. I'm coding on a mac (as I am a graphic designer), so that is the latest IE version available to me.

    Is there anything I can do to this code to make it work in IE for mac?

    Thanks in advance

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by junip
    Is there anything I can do to this code to make it work in IE for mac?
    ignore Mac IE, it's a POS. seriously, M$ have stopped supporting it, so why should you. IE on the Mac is so bug ridden I'm surprised the UN haven't banned it under the Biological Weapons Convention.

    best thing to do is to trap its users and instruct them to use another browser.
    *keep it simple (TM)

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Array.push method is not supported in IE Mac. You need to add this in your page:
    Code:
    if(typeof Array.prototype.push=='undefined')
        Array.prototype.push=function(){
            var
                i=0,
                b=this.length,
                a=arguments;
            for(i;i<a.length;i++)
                this[b+i]=a[i];
            return this.length
        };
    For other array functionalities not fully implemented by some browsers, please refer to this.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Without Links?

    Hey!

    This is really an excellent script. I want to use it for a project of mine but I don't need the links ... just the images. What is the best way of removing the links?

    Also, there is a blue border around each image. I guess this will be removed if I remove the links?

    Thanks a lot.


  •  

    Posting Permissions

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