GetGadgetAttribute // Canvas // iframe

Using Javascript from SpiderBasic
User avatar
Arbrakaan
Posts: 91
Joined: Mon Feb 24, 2014 10:54 pm
Location: Geneva
Contact:

GetGadgetAttribute // Canvas // iframe

Post by Arbrakaan »

Hello all,

There is a way to get the image of a <canvas> element from a iframe ?

I get the canvas element with this in JS :
v_canvas = document.getElementsByTagName("iframe")[0].contentWindow.document.getElementsByTagName("canvas")[0]

But i cant pass it to GetGadgetAttribute() it return nothing....

here some code :

Code: Select all

  !v_canvas = document.getElementsByTagName("iframe")[0].contentWindow.document.getElementsByTagName("canvas")[0]
  ;Debug canvas
  imageID = GetGadgetAttribute(canvas, #PB_Canvas_Image )
  ExportImage(imageID, "test",#PB_ImagePlugin_PNG)
Thanks for the help :)
poshu
Posts: 96
Joined: Mon Feb 24, 2014 11:46 pm

Re: GetGadgetAttribute // Canvas // iframe

Post by poshu »

I'm... not sure what you are trying to achieve.
A canvas in SB is not a direct representation of an HTML5 canvas and SB's id are not elements.
You can only use GetGadgetAttribute(id,#PB_Canvas_Image ) on a gadget created through the function CanvasGadget(id[...]).

Now, from what I get of your specific need : you can use the toDataURL() method on your canvas element and open the result using spiderbasic's LoadImage().

Also, to get support it's always better to post actual code so we can understand your problem, my crystal ball is at the repair shop right now...
User avatar
Arbrakaan
Posts: 91
Joined: Mon Feb 24, 2014 10:54 pm
Location: Geneva
Contact:

Re: GetGadgetAttribute // Canvas // iframe

Post by Arbrakaan »

Thanks for the quick answer, and sorry for my delay.

It work fine with the toDataURL () methode, thanks.

A way to add a ID to a elment and play with it in SpiderBasic would be usefull, somthing like this maybe ?

SetElementID (#gadget, id)
GetElementID (#gadget)


Thanks a lot for the help, and sorry for my bad english...
Post Reply