
Originally Posted by
orbitty
http://www.dynamicdrive.com/dynamici...geselector.htm
I like this script very much, however I believe there's one essential thing missing....
Please can any one tell me how I can
add a link to the images ?
(and how come Dreamweaver MX 2004 crashes everytime when I try to edit the page with the current script??)
Thank you very much in advance !
Use a text editor to edit scripts. You may even have to go so far as maintaining separate versions of the page, one without the script for use in Dreamweaver and one that is the finished version with the script that only gets edited in a text editor. Here are the changes you can make to the Dynamic image selector script to allow for robust linking options, first add this style block to the head:
Code:
<style type="text/css">
#link {
text-decoration:none;
display:block;
color:black;
width:225px;
}
#link img {
border:none;
}
#link:hover {
color:blue;
}
</style>
You can edit the property/value pairs to suit. Next, replace the description array with this one:
Code:
//enter image descriptions, links ("" for blank)
var description=new Array()
description[0]=["DHTML: The Definitive Guide", "href='http://www.google.com'"] //simple link
description[1]=["DHTML Visual QuickStart Guide", "href='http://www.dynamicdrive.com' target='_blank'"] //link w/target
description[2]=["HTML 4 and DHTML", ""] //no link
description[3]=["IE5 DHTML Reference", "href='javascript:alert(\"Hi!\")'"] //link as javascript event
Find this line in the script:
Code:
contentobj.innerHTML='<center><img src="'+which+'"><br><br>'+description[tempobj.options.selectedIndex]+'</center>'
Replace it with this one:
Code:
contentobj.innerHTML='<center><a '+(description[tempobj.options.selectedIndex][1]!==""? 'id="link" ' : '')+description[tempobj.options.selectedIndex][1]+'><img src="'+which+'"><br><br>'+description[tempobj.options.selectedIndex][0]+'</a></center>'
Finally, to maintain NS4 compatibility, change this line:
Code:
document.dynamic1.document.dynamic2.document.write('<center><img src="'+which+'"><br><br>'+description[tempobj.options.selectedIndex]+'</center>')
to this:
Code:
document.dynamic1.document.dynamic2.document.write('<center><img src="'+which+'"><br><br>'+description[tempobj.options.selectedIndex][0]+'</center>')
Bookmarks