Script: DHTML slide show (manual)
http://www.dynamicdrive.com/dynamici...dhtmlslide.htm
I'm having trouble and need help adding a getAttribute method to this script. Here's what I'm trying to accomplish: I don't want to mess with resizing my pictures to fit on my page, I just want to control the placeholder. To do that, I need to dynamically determine the height of the array picture being used at runtime. If the height is >300, I want to calculate a "factor" variable (300 / img height), store 300 to a height variable, multiply the factor times the width and store that to a width variable. Then, on the line that writes the image object, assign the height and width attributes using the calculated variables. Otherwise, if the original image height is <300, store the original image's width and height attributes to those variables. Here's what I did (see the original script):
var preloadedimages=new Array()
for (i=0;i<photos.length;i++){
preloadedimages[i]=new Image()
preloadedimages[i].src=photos[i]
var picHeight = photos[i].getAttribute(height) // Added this line
var picWidth = photos[i].getAttribute(width) // Added this line
}
then added this to the actual display routine:
<script language="JavaScript" type="text/javascript">
if (linkornot==1)
document.write('<a href="javascript:transport()">')
if (picHeight>300) { //Added this line
factor = 300 / picHeight //Added this line
dispWidth = picWidth * factor //Added this line
dispHeight = 300 //Added this line
} else { //Added this line
dispWidth = picWidth //Added this line
dispHeight = picHeight //Added this line
} //Added this line
document.write('<img src="'+photos[0]+'" name="photoslider" style="filter:revealTrans(duration=2,transition=23)" border=0 width=dispWidth height=dispHeight>')
if (linkornot==1)
document.write('</a>')
</script>
But it doesn't work. If anyone has a great idea to make this work, it would be the most killer slide show in the collection. Thanks!
Regards,
TechhieTim



Reply With Quote


Bookmarks