SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member dcakru's Avatar
    Join Date
    May 2004
    Location
    Manitoba
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How Do I Make This Work?

    On my Local Wedding Resources Page, I have a graphic that i want to link to four different sites. When it is clicked on, i want it to choose one of the four sites, but not the same one every time. The sites are:
    www.marykay.ca/cunrau
    www.marykay.ca/lihiebert
    www.marykay.ca/eblatz
    www.marykay.ca/ewaters

    Can anyone help me with this one?

  2. #2
    SitePoint Guru Marc's Avatar
    Join Date
    Nov 2000
    Location
    New York
    Posts
    765
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A quick search on google revealed this javascript, which looks like it will do the trick quite well:

    http://javascriptkit.com/script/cut1.shtml
    Marc Gugliuzza
    marc.gugliuzza.com



  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Presumably, you want the links to run in sequence, one after the other, and then loop around. No randomness called for.
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
    <title>Untitled Document</title>
    <style type="text/css">
    
    body {
    	background: url(http&#58;//www.geocities.com/toriclaybourne/bonesskull1sm.gif);
    }
    img {
    	width: 182px;
    	height: 300px;
    	margin: 40px;
    	border: 8px silver ridge;
    }
    
    </style>
    <script type="text/javascript">
    
    LinkLoop.prototype.hrefs  = [ 
    				'http://www.marykay.ca/cunrau' , 
    				'http://www.marykay.ca/lihiebert' , 
    				'http://www.marykay.ca/eblatz' , 
    				'http://www.marykay.ca/ewaters'   //no trailing comma!
    			     ];
    
    LinkLoop.prototype.winflag = 'CURRENT_LINK_IDX_';
    
    function LinkLoop()
    {
    	this.link_num = this.hrefs.length;
    	this.curr_link_idx = 0;
    	this.next_link_idx = 1;
    	this.namechk = new RegExp(this.winflag + '\\d+');
    	this.nextlink = function(currhref)
    	{
    		if (!this.namechk.test(self.name))
    		{
    			self.name = String(this.winflag + this.next_link_idx);
    			return currhref;
    		}
    		else
    		{
    			this.curr_link_idx = Number(self.name.split(this.winflag)[1]);
    			this.next_link_idx = (this.curr_link_idx + 1 == this.link_num) ? 0 : this.curr_link_idx + 1;
    			self.name = String(this.winflag + this.next_link_idx);
    			return this.hrefs[this.curr_link_idx];
    		}
    	}
    }
    
    var linkloop = new LinkLoop();
    
    </script>
    </head>
    <body>
    <a href="http://www.marykay.ca/cunrau" onclick="this.href=linkloop.nextlink(this.href)">
    <img title="R.I.P." src="http://www.famoustexans.com/images/marykaye.gif" />
    </a>
    </body>
    </html>
    
    ::: certified wild guess :::

  4. #4
    SitePoint Member dcakru's Avatar
    Join Date
    May 2004
    Location
    Manitoba
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks That's wonderful!


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
  •