Any way to display some heavily-styled HTML in isolation from the rest of site's styles?

前端 未结 5 744
暗喜
暗喜 2020-12-18 07:15

I am trying to figure out a way to display an archive of email newsletters on my client\'s site. The issue is that the newsletters are full of a zillion inline styles, whic

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 08:02

    9 years later and there still isn't a better solution.

    If you don't have an external source (you can't add html into a frame manually) you need to use js to insert the messy html/css (in my case I use it to view emails)

    
    

    and js:

    const frame = document.querySelector('.my-frame');
    
    frame.contentWindow.document.open('text/html', 'replace');
    frame.contentWindow.document.write(hereGoesYourMessyHtmlCss);
    frame.contentWindow.document.close();
    

提交回复
热议问题