Closed Riccsson closed 1 year ago
Sorry, i found it: canvas = H5.Core.dom.document.getElementById<H5.Core.dom.HTMLCanvasElement>(canvasId);
No worries! Usually I add to the usings list this import, so you can use it directly without having to prefix with the whole namespace:
using static H5.Core.dom;
//...
var canvas = document.getElementById<HTMLCanvasElement>(canvasId);
//Just that you know, another useful method when handling DOM objects is the .As<T>(), it performs a "fake cast" to the final type:
var canvas = document.getElementById(canvasId).As<HTMLCanvasElement>();
canvas = Bridge.Html5.Document.GetElementById
(canvasId); How do I use this line of code in H5?
@Riccsson
HTMLCanvasElement element = Document.GetElementById<HTMLCanvasElement>("id");
You need to add h5 nuget package and namespace H5.Html5;
to project and it will work;
I didnt find namespace H5.Html5. So I use H5.Core.dom instead.
The .As
I didnt find namespace H5.Html5. So I use H5.Core.dom instead. The .As() was a good thing +1 Thank you
@Riccsson
You are right, I forgot that I ported it from Bridge.Frameworks to separate library. So it is available for me as usual.
P.S. I use own fork of H5 built with .NET 6 instead of .NET 7 as well.
canvas = Bridge.Html5.Document.GetElementById(canvasId);
How do I use this line of code in H5?