My question is about inserting <canvas></canvas>
into a mediawiki page.
(Edit: This codes works, but it takes about 5 minutes for it to register, see below for full answer)
I was able to put a javascript "Hello World" out put onto my mediawiki site.
To do so I have the following:
- In my MediaWiki:Common.js page I have:
(function () {
var myElement = document.getElementById('mw-hello-world');
myElement.innerHTML = '<html>Hello World!!!</html>';
}());
- In my Template:Helloworld page I have:
<div id="mw-hello-world"></div>
- In my main page I have:
{{Helloworld}}
I now want to put a <canvas></canvas>
on my main page. A guy at Mediawiki called Bawolff said the following
"You would need to write an extension
(Or put it entirely in a javascript file like the page MediaWiki:Common.js on your wiki)"
The problem is, <canvas></canvas>
doesn’t work by itself on any page. So I am wondering where to put <canvas></canvas>
.
As you all can tell, I’m not a real programmer, so I was hoping for some ideas.
Thanks
Aslo, I did try doing the above, but with the code:
(function () {
var myElement = document.getElementById('mw-Mycanvas');
myElement.innerHTML = '<html><canvas width="200" height="100" style="border:1px solid red;"></canvas></html>';
}());
And then changing everything appropriately. But it just comes up as blank. But if I do this in HTML I get a red box.
2
Answers
Ok. The code I wrote actually does work. But I guess there was some kind of delay, of about 5 minutes. I don't know. I will try InSync's suggestions also and post the results. Thanks
I wrote the following:
This is the way to go:
Or:
References:
document.createElement()
Node#appendChild()