Robert Ehinger
asked on
Web Page Button with Save As option
This is the web page where I have the sample code I am working with. I want to use javascript to create a button that will allow the user to download the image they see on the screen. So far all I have been able to get is the image in a new page with no header. What I want is a "Save As" pop up option. How can I accomplish this.
http://www.mrtechnology1954.com/santaclaus/santa24.html
Thank you!
Robert
http://www.mrtechnology1954.com/santaclaus/santa24.html
Thank you!
Robert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The best way to do this really is on the server.
Some other options are the HTML5 download attribute, that is for link, not button:
http://davidwalsh.name/download-attribute
Though that doesn't work on my browser. (Firefox, Ubuntu)
You could also base64 encode the image. Though your image is huge. See example:
http://jsfiddle.net/5whKM/
I've seen people claim they can extract the the img src and change the type to data:application/octet-str eam forcing the browser to open a Save As dialog, but again I cannot recreate this in my env.
Some other options are the HTML5 download attribute, that is for link, not button:
http://davidwalsh.name/download-attribute
Though that doesn't work on my browser. (Firefox, Ubuntu)
You could also base64 encode the image. Though your image is huge. See example:
http://jsfiddle.net/5whKM/
I've seen people claim they can extract the the img src and change the type to data:application/octet-str
ASKER
I have Dreamweaver CS4 which is what I used to build all the pages associated with this site. I can easily add a button to the page but I don't know where to go to get the appropriate actions that I want associated with the button.
I think what pinish and I are both saying is that the proper way to do this is to use a server side script to set the content type and serve the image.
Do you have php available on your server?
Any javascript actions you can associate with the button are client side scripts only and will not actually do what you are looking for.
Do you have php available on your server?
Any javascript actions you can associate with the button are client side scripts only and will not actually do what you are looking for.
ASKER
the server where this will ultimately reside does not have php available. Are there any other options? If I have to use the javascript how can I control the size of the image and is there a way to have it centered on the screen when it is opened?
ASKER
The owner of the web site decided he just needed for the visitor to be able to print the image with no header. That has been accomplished so the problem is resolved.
ASKER