Page 1 of 1

GetGadgetAttribute // Canvas // iframe

Posted: Mon Feb 04, 2019 12:20 am
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 :)

Re: GetGadgetAttribute // Canvas // iframe

Posted: Mon Feb 04, 2019 1:55 am
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...

Re: GetGadgetAttribute // Canvas // iframe

Posted: Thu Feb 07, 2019 9:34 am
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...