For #1, change the image array to this:
Code:
var fadeimages=new Array()
//SET 1) IMAGE PATHS, 2) optional link, 3), optional link target, 4) optional title attribute:
fadeimages[0]=["photo1.jpg", "", "", ""] //plain image syntax
fadeimages[1]=["photo2.jpg", "http://www.google.com", "", ""] //image with link syntax
fadeimages[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new", ""] //image with link and target syntax
fadeimages[3]=["photo4.jpg", "http://www.javascriptkit.com", "_new", "Contact Us"] //image with link, target and title syntax
Add to the insertimage function (additions red):
Code:
function insertimage(i){
var tempcontainer=fadeimages[i][1]!=""? '<a href="'+fadeimages[i][1]+'" target="'+fadeimages[i][2]+'">' : ""
tempcontainer+='<img src="'+fadeimages[i][0]+'" title="'+fadeimages[i][3]+'" border="0">'
tempcontainer=fadeimages[i][1]!=""? tempcontainer+'</a>' : tempcontainer
return tempcontainer
}
For number #2, you can make an external file, call it say, fade.js. Put everything in it from the original script except:
<script language="JavaScript1.2" type="text/javascript">
from the top and:
</script>
<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided by<br>
<a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>
from the bottom. Also. leave out this section:
Code:
var fadeimages=new Array()
//SET 1) IMAGE PATHS, 2) optional link, 3), optional link target:
fadeimages[0]=["photo1.jpg", "", ""] //plain image syntax
fadeimages[1]=["photo2.jpg", "http://www.google.com", ""] //image with link syntax
fadeimages[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax
Now, in the body of each page where the script would have gone originally, put this:
Code:
<script type="text/javascript">
/***********************************************
* Fade-in image slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var fadeimages=new Array()
//SET 1) IMAGE PATHS, 2) optional link, 3), optional link target, 4) optional title attribute:
fadeimages[0]=["photo1.jpg", "", "", ""] //plain image syntax
fadeimages[1]=["photo2.jpg", "http://www.google.com", "", ""] //image with link syntax
fadeimages[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new", ""] //image with link and target syntax
fadeimages[3]=["photo4.jpg", "http://www.javascriptkit.com", "_new", "Contact Us"] //image with link, target and title syntax
</script>
<script src="fade.js" type="text/javascript"></script>
Bookmarks