PDA

View Full Version : JavaScript - Adding .pdf file extention to "<a href=" output



myyoungfamily
03-29-2006, 02:34 AM
This is a JavaScript question although it is in regards to this php script: http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

Here's my trouble...
I believe the script below is used to output an "<a href=" path to an image. I need to be able to add a ".pdf" file extention to the path being output by this script.

Instead of the path being: http://www.site.com/pic1.jpg
I need the path to be: http://www.site.com/pic1.jpg.pdf


function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}

My reason for doing this is so I can use the gallery image thumbnail for viewing purposes and when it gets clicked the "<a href=" will link to a dowloadable pdf.

jscheuer1
03-29-2006, 07:45 AM
Well, if all you need is for this part:


var tempcontainer='<a href="'+imagecompletepath+'" . . .

to give you the path to the image and the image filename with '.pdf' added at the end, just add it like so:


var tempcontainer='<a href="'+imagecompletepath+'.pdf" . . .