0

I create img element with a jquery plugin.

I would like to be able to click a button element and dowload the img element.

Is it possible without HTML5?

I do not store the image, cause it is created on the fly by jquery.

i'm using this plugin to create the img: http://www.class.pm/files/jquery/jquery.uqr/demo/

itsme
  • 48,972
  • 96
  • 224
  • 345

2 Answers2

1

The plugin you linked is using Google's deprecated Image Charts portion of Google Charts. Since the images come from a remote server, you can't access them (from JavaScript. Of course you can load them) from your domain (it would be a form of XSS). You can make a PHP script to download a chart and change the Content-Type. When the client requests a PHP script that returns a document with Content-Type application/octet-stream, the download will commence.

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196
1

Since this is from a different domain, you won't be able to access image contents, unless you try to use CORS - and even then, there's very limited browser support. Use this plugin instead and then use toDataURL() to save it.

tmcw
  • 11,536
  • 3
  • 36
  • 45
  • now i have this problem http://stackoverflow.com/questions/12804428/dataimage-not-saving-as-image-on-mac-pc#comment17316182_12804428 :( – itsme Oct 10 '12 at 08:06