Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-24-2010, 10:29 PM   PM User | #1
martin_b14
New to the CF scene

 
Join Date: Jul 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
martin_b14 is an unknown quantity at this point
Adding html links to an array

I have used this daily changing image script, it works well but I would like to add html links to each image. But I don't know how to do it.

So instead of the array '1_side.jpg' '2_side.jpg' I would like somethinlike this:

'<a href="'1_side.html"><img src'1_side.jpg"/></a>',
'<a href="'2_side.html"><img src="'2_side.jpg"/></a>',
'<a href="'3_side.html"><img src="'3_side.jpg"/></a>', and so on.

Thanks in advance

Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Daily Picture - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">

/* Daily Pic ©2007 John Davenport Scheuer
* This notice must remain for legal use */

if(document.images&&document.getElementById)
var daily={
diurnal:true, //should script split between noon to midnight, midnight to noon if enough images are available? (true/false)
path:'file://localhost/C:/sites/mysite/images/', //set absolute path to images here, and list them (minimum 31 required) on the next line
pics:['1_side.jpg','2_side.jpg','3_side.jpg','5_side.jpg','8_side.jpg','leroy.jpg','leroy_o.jpg','lilac.jp g','lilac_sm.jpg','photo1.jpg','photo10.jpg','photo1_h1.jpg','photo1_h2.jpg','photo1_thumb.jpg','pho to2.jpg','photo2_h1.jpg','photo2_h2.jpg','photo2_thumb.jpg','photo3.jpg','photo3_h1.jpg','photo3_h2. jpg','photo3_thumb.jpg','photo4.jpg','photo4_h1.jpg','photo4_h2.jpg','photo4_thumb.jpg','photo5.jpg' ,'photo5_h1.jpg','photo5_h2.jpg','photo5_thumb.jpg','photo6.jpg','photo6_h1.jpg','photo6_h2.jpg','ph oto6_thumb.jpg','photo7.jpg','photo7_h1.jpg','photo7_h2.jpg','photo7_thumb.jpg','photo8.jpg','photo8 _h1.jpg','photo8_h2.jpg','photo8_lrg.jpg','photo8_thumb.jpg','photo9.jpg','photo9_h1.jpg','photo9_h2 .jpg','photo9_lrg.jpg','photo9_thumb.jpg','thumb1.jpg','thumb2.jpg','thumb3.jpg','35.gif','36.gif',' 37.gif','38.gif','40.gif','dynamicbook1.gif'],
///////////////// Stop Editing /////////////////
tag:function(){return document.getElementById('dcontent');},
d:new Date().getDate()-1,
h:function(){return new Date().getHours()<12? 0 : 1;},
img:document.createElement('img'),
pic:function(){
var d=daily;
for (var a=[], i = 0; i < d.pics.length; ++i)
a.push([d.pics[i++], d.pics[i]]);
d.img.src=d.diurnal&&a[d.d][d.h()]? d.path+a[d.d][d.h()] : d.path+d.pics[d.d];
d.img.title=d.img.alt='Daily Image';
d.tag().appendChild(d.img);
}};
if(document.images&&document.getElementById)
window.onload=daily.pic;
</script>
</head>
<body>
<div id="dcontent"></div>
</body>
</html>
martin_b14 is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript array links

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:28 AM.


Advertisement
Log in to turn off these ads.