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

GetGadgetAttribute // Canvas // iframe

by Arbrakaan Mon Feb 04, 2019 12:20 am

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: 85
Joined: Mon Feb 24, 2014 11:46 pm

Re: GetGadgetAttribute // Canvas // iframe

by poshu Mon Feb 04, 2019 1:55 am

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: 83
Joined: Mon Feb 24, 2014 10:54 pm
Location: Geneva

Re: GetGadgetAttribute // Canvas // iframe

by Arbrakaan Thu Feb 07, 2019 9:34 am

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...
Return to Javascript

Who is online

Users browsing this forum: No registered users and 1 guest