Jump to content

how to programatically create multiple canvases?


Aerion
 Share

Recommended Posts

var canv = document.createElement ( 'canv1' );

document.children [ 0 ].appendChild ( canv );

alert ( document.getElementById ( 'canv1' ) );

Uncaught TypeError: Cannot read property 'getContext' of null

Why am I receiving this error? :( I just wanna create multiple canvases...

Link to comment
Share on other sites

5 hours ago, Mythros said:

@RaananW

ok : 

var canv = document.createElement ( 'canvas' );

document.children [ 0 ].appendChild ( canv );

this works but why is it showing a white screen when all my files are loading correctly?

Sorry but this question is so void of detail it is unanswerable even by Derren Brown (English Mindreader).

Link to comment
Share on other sites

for(var i=0; i < 10;  i++){
var cvas = document.createElement('canvas');
cvas.setAttribute('id', 'renderCanvas'+i);
cvas.classList.add('canvas-thingy');
var target = document.body || what ever...
target.appendChild(cvas);

}


Errors on your page:
3infinityfree.net/errors/404 Failed to load resource: the server responded with a status of 404 ()
main.php:1 Failed to load https://infinityfree.net/errors/404: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://babylontesting.epizy.com' is therefore not allowed access. The response had HTTP status code 404.
2infinityfree.net/errors/404:1 GET https://infinityfree.net/errors/404 404 ()
main.php:1 Failed to load https://infinityfree.net/errors/404: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://babylontesting.epizy.com' is therefore not allowed access. The response had HTTP status code 404.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...