Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    28
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Allowing a download but not following a link

    Apologies for the title. I couldnt express myself in short.

    Anyhow, what I want to do is make an anchor like this:

    <a onlick="DoSomethingOrOther" href="location/tune.mp3">Text</a>

    so that the user can click and DoSomethingOrOther, or right click and have the option to download "tune.mp3". However, the presence of the href means that when they click, they follow the link. If I take it away, they can't follow the link, but they also can't do the download.

    Is there any way I can do this? Thanks!

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello brichcja,
    Have you seen a particular site that has the download behaviour you want?

    The best I can suggest might be a target="new" so the download opens up in another window. There might be a js solution that opens up a small download box, try google for that.

    Here's some options - http://www.goldcoastwebdesigns.com/c...oad-link.shtml
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    28
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Reply

    Thanks for that. I solved it!


  •  

    Posting Permissions

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