0

when ever we load something with an iframe , everything loads in its seperate dom root.

so thats great one iframes css,js dont get affected by existing stuff on the page .

I was wondering is there a way to create a div but have that div stay in it's own dom document root without using an iframe ?

so fore example i can place htm css js in that div but because it would run like an iframe and run in its own dom document root.

can this be done ? or is just using iframes is the only way.

     <iframe rel="prerender"  src="https://www.mypage.com/custom.html" > 
   </iframe>
user3548161
  • 119
  • 5
  • 18
  • 5
    you might want to take a look at [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) they use shadow dom which encapsulates styles. Encapsulating JS is not possible with this but shouldn't be needed anyhow. – cloned Jul 22 '19 at 12:05
  • Possible duplicate of [How exactly can I replace an iframe with a div and Javascript?](https://stackoverflow.com/questions/10040297/how-exactly-can-i-replace-an-iframe-with-a-div-and-javascript) – Jaydeep Jul 22 '19 at 12:08
  • please explain little more or give any example so that it will be easy for us – Soubhagya Kumar Barik Jul 22 '19 at 12:09
  • Well when you use pjax , js and css dont get re initialized you have to manually reinitialize it in every single page . I guess there is no solution to this . and no jd this is not a duplicate there is a difference in this question of having elements run in there own seperate dom roots just like iframe does, key word dom root .. the good example of runing elements in own seperate dom roots is using 5 or 6 iframes . but thats not good hence the initial reason for asking this question. – user3548161 Jul 23 '19 at 04:49

0 Answers0