admin管理员组

文章数量:1429201

The below code works in chrome but not in Internet Explorer. Is there any way to use it in Internet Explorer?

    <html>
      <head></head>
     <body>
  <div>
    <h4>My Content Heading</h4>
    <p>My content text</p>
  </div>

  <script>
   var myContent = document.querySelector('div');  
   var shadowroot = myContent.createShadowRoot(); 
   shadowroot.innerHTML =
   '<h2>Inserted Heading</h2> <content select="p"></content>';
  </script>
  </body>
</html>

The below code works in chrome but not in Internet Explorer. Is there any way to use it in Internet Explorer?

    <html>
      <head></head>
     <body>
  <div>
    <h4>My Content Heading</h4>
    <p>My content text</p>
  </div>

  <script>
   var myContent = document.querySelector('div');  
   var shadowroot = myContent.createShadowRoot(); 
   shadowroot.innerHTML =
   '<h2>Inserted Heading</h2> <content select="p"></content>';
  </script>
  </body>
</html>
Share Improve this question asked Jul 30, 2015 at 10:02 sivakumaros2004sivakumaros2004 211 silver badge3 bronze badges 1
  • not supported in IE11 – Jaromanda X Commented Jul 30, 2015 at 10:07
Add a ment  | 

1 Answer 1

Reset to default 3

Internet explorer (and new Edge browser) doesn't support shadow DOM natively. You can use polyfill to achieve desired behaviour.

本文标签: javascriptusing shadow dom in Internet ExplorerStack Overflow