Results 1 to 2 of 2

Thread: JavaScript - Adding .pdf file extention to "<a href=" output

  1. #1
    Join Date
    Jul 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaScript - Adding .pdf file extention to "<a href=" output

    This is a JavaScript question although it is in regards to this php script: http://www.dynamicdrive.com/dynamici...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

    Code:
    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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, if all you need is for this part:

    Code:
    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:

    Code:
    var tempcontainer='<a href="'+imagecompletepath+'.pdf" . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •