Search code examples
cssembedding

Separate styles of embeded page


I have a situation where I'm getting the html for a page, and inserting it into a div on the current page. When this happens, the styles of the inserted page can perpetrate out to the holding page, and mess it up.

Here is a sample screenshot of one of many style issues that occur: sample screenshot

I'm building a chrome extension that formats your search results into a sidebar, and loads each result you click on on the right.


Solution

  • I suggest going through the loaded div in javascript and cleaning off any inline styles (class names and style attributes). You can either use a javascript library (eg jquery's attribute selectors) or an xpath query to find the nodes. It's probably the most reliable method.