William
William

Reputation: 4588

How to create custom HTML elements

I am doing this tutorial here

I simply copied and pasted the code below.

var XFoo = document.register('x-foo');
document.body.appendChild(new XFoo());

I immediatly get an error saying that:

Uncaught TypeError: Object #<HTMLDocument> has no method 'register' 

I do not know why nor what I am doing wrong. I am using the Chrome browser.

Upvotes: 2

Views: 661

Answers (2)

Dominic Cooney
Dominic Cooney

Reputation: 6545

I implemented Custom Elements in Chrome so I might be able to help.

Starting with Chrome 33, document.register has been renamed document.registerElement.

Up to Chrome 32, the most likely reason you would get that error is if the Experimental Web Platform Features flag is not enabled. Cut and paste chrome://flags into the Omnibox and hit enter to check. After changing flags, you have to restart your browser for the changes to take effect.

HTH!

Upvotes: 4

Vikram Rao
Vikram Rao

Reputation: 514

Only firefox and chrome are known to support it yet. If you are trying it in IE, Safari or Opera then you are out of luck.

Upvotes: 0

Related Questions