<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Web Component : template support</title> </head> <body> <h1 id="message"></h1> <script> var isTemplateSupported = function(){ var template = document.createElement('template'); return "content" in template; }; var isSupported=isTemplateSupported(), message=document.getElementById("message"); if(isSupported){ message.innerHTML="Template element is supported by the browser."; } else{ message.innerHTML="Template element is not supported by the browser."; } </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Web Component : A inert template content example.</title> </head> <body> <div id="message"></div> <template id="aTemplate"> <img src="http://www.tutorialsavvy.com/wp-content/uploads/2014/11/ReactJS-830-8301-300x300.png" id="profileImage"> <script> alert("this is a script"); </script> </template> <script> (function(){ var imageElement=document.getElementById("profileImage"), messageElement=document.getElementById("message"); messageElement.innerHTML="IMG element "+imageElement; })(); </script> </body> </html>