Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.
Starts at just $1 per CPM or $0.10 per CPC.
I was trying to find a solution to my problem, which is:
How to trigger the "Save Image As" dialog window to open using Javascript?
My problem is that the files that are going to be saved are dynamically created images, and I'm trying to avoid "right click">>"save image as"
I searched the web, but still no working solution...I will be happy to hear what the DP members think about this.
Thanks in advance.
You can write a simple php script that retrieves the page than uses a regexp to retrieve the img src.
Post in the PHP forum if you want to look deeper into this solution.
I know how to do this with php, thanks for the not so accurate advice anyway.
I'm trying to find out how can you do this with Javascript, if this is possible of course.
Click to expand...
You must have a reason for needing javascript.
That is why I asked you in my first post;
What is it you are trying to do?
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == ‘object’)
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout(’win.document.execCommand(â€SaveAsâ€)’, 500);
</script>
<input name="Salva Imagine" type="button" onClick="saveImageAs (document.getElementByID('embedImage'))" value="Salva" />
<a href="#" ONCLICK="saveImageAs(document.getElementById('embedImage')); return false" >save image</a>
<img id="embedImage" src="../apache_pb2.gif" width="259" height="32" >
Code (markup):
I'm totally newbie with JAVA so someone could explain how to use it?
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == 'object')
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout('win.document.execCommand("SaveAs")', 500);
</script>
<A HREF="javascript: void 0"
ONCLICK="saveImageAs(document.anImage); return false"
>save image</A>
<IMG NAME="anImage" SRC="../apache_pb2.gif">
</body>
Code (markup):
Unfortunely It work only with IE not FireFox
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == 'object')
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout('win.document.execCommand("SaveAs")', 500);
</script>
<A HREF="javascript: void 0"
ONCLICK="saveImageAs(document.anImage); return false"
>save image</A>
<IMG NAME="anImage" SRC="../apache_pb2.gif">
</body>
Code (markup):
Unfortunely It work only with IE not FireFox
Click to expand...
As I said in my first post.
I wanted to pop up a save as dialog box to prompt the user to save the charts on my webpage to be saved as an image in his/her machine.
The below code works fine,but the new window opens where actually the saving of data is taking place before the pop up of save as box.
How to avoid the new window opening
Below is the code
<script type = "text/javascript">
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == 'object')
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout('win.document.execCommand("SaveAs")', 500);
</script>
<img name="anImage" src="../ProductBacklog/ChartImages/chart.jpeg" visible = "false" style="width: 1px"/>
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == 'object')
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout('win.document.execCommand("SaveAs")', 500);
</script>
<A HREF="javascript: void 0"
ONCLICK="saveImageAs(document.anImage); return false"
>save image</A>
<IMG NAME="anImage" SRC="../apache_pb2.gif">
</body>
Code (markup):
Unfortunely It work only with IE not FireFox[/QUOTE
Hi the above script opens up the image in a new window before pop up can anyone suggest how avoid it
Click to expand...
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == 'object')
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout('win.document.execCommand("SaveAs")', 500);
</script>
On an imagebutton I am calling the above script <ClientSideEvents Click='javascript:saveImageAs(document.anImage)' />
<img name="anImage" src="../ProductBacklog/ChartImages/chart.jpeg" visible = "false" style="width: 1px"/>
The above location is the place where charts are getting generated dynamicallyu based on the project chosen from dropdown.
oN CLICK i AM GETTIN A NEW WINDOW OPENED with address http...ProductBacklog/ChartImages.
The chart is in aspx page in ProductBacklog folder.
How to avoid this page getting opened ,since this opens up and then the above script pops up Save AS DIALOG BOX.
Please any help would be appreciated.
The work-around avoiding a new browser window opening is as follows:
The save-as script in the header:
<script>
function SaveFile(fname){
img.document.execCommand('saveas', null ,fname)
</script>
Now the trick is to have the image already opened as a new page.
To achieve this we put it in an iframe with the image filename as SRC:
<iframe id="img" src="myimage.jpg" width="(image width + 20)px" height="(image height + 25)px" scrolling="no" frameborder="0px"></iframe>
On the original page we now call the save-as script:
<button onclick="SaveFile('myimage.jpg');">save as</button>
Does not work in FireFox though.....
<script>
function SaveFile(fname){
document.getElementById('img').contentWindow.document.execCommand('saveas', null ,fname);
</script>
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == 'object')
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout('win.document.execCommand("SaveAs")', 500);
</script>
<A HREF="javascript: void 0"
ONCLICK="saveImageAs(document.anImage); return false"
>save image</A>
<IMG NAME="anImage" SRC="../apache_pb2.gif">
</body>
Code (markup):
Unfortunely It work only with IE not FireFox
Click to expand...
That's not much of a problem, seing that IE has a 70% market share.