Getting CSS content to run correctly in an iFrame, or PageView Webpart in SharePoint.

Posted on 2015-02-08
Last Modified: 2015-04-17
I am attempting to get an HTML page with attached CSS to run within a SharePoint page.  Ideally, I would like to save the html file in a document directory, and point pageview web parts at the file from different locations within a SharePoint portal.  The page loads and runs perfectly outside of SharePoint, and it uses the CSS checkbox hack to update the visible content of a page when a user clicks on a checkbox label.  

Within SharePoint, the checkbox label select is not registered, and the style information within the <div> with conent is not read.  My question is, is there a way to get the page content within an iFrame, or pageview web part to be seperate from the SharePoint page styles.  Clearly, the style settings within the portal page are getting higher priority, but also, the checkbox technique is not working either.  

I understand that getting pseudo classes on non anchor tags can be a problem in SharePoint, but I thought that it would be possible to do this with iFrames.
Question by:pjenrow
  • 4
  • 2
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 40598583
sorry but could you please either provide a link or a sample HTML, script and CSS code?
Which SharePoint version and edition?

Author Comment

ID: 40598792
Some additional detail on the content I would like to link with an iFrame.  The version of SharePoint is 2013, but currently operating in SharePoint 2010 emulation.  I was unable to get this to work in SharePoint 2010.  I have attached a sample html, and CSS file for additional information.
LVL 53

Expert Comment

ID: 40599075
It is unlikely that sharepoint is going to be able to do what you want.  Technically you are creating a security violation, and the HTML page in an iframe is not going to let Sharepoint reference or execute code.  Because sharepoint runs as an application rather than coming from a web server, the web page sees the relationship as being cross domain, even if the pages are in the same directory as sharepoint.

There was a time when frames and iframes were used as attack vectors, so it is necessary to have what is essentially a firewall to prevent cross-domain manipulation.  

I am not a Sharepoint expert so I don't know if you can resolve it by delivering the sharepoint parent from the web server where the page is coming from in which case it might clear the security violation.

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.


Author Comment

ID: 40599589
I wanted to add some additional information related to the sample I included.  I had no problem with the JavaScript running in the iFrame within SharePoint.  In fact, all aspects ran correctly with the exception of the styling within the <div class="container"> section.  At first the code used an HTML 5 tag <section>, and I thought that might be the problem, so we changed it to a div with class="container".  My problem is getting the checkbox labels to be checked.  

I have read that SharePoint 2010 has conflicts with html 5 tags.  

While its possible that I can't get the css to function right through the iFrame, I did get JavaScript to run.
LVL 53

Expert Comment

ID: 40601061
It is possible that Sharepoint just cannot support the CSS.  Microsoft had a history of not being able to support a lot of the CSS standards up until around 2012 as it phased out support for older technologies like xp and IE7. Sharepoint 2010 probably support the CSS at the IE8 level which was still based on the old MS model of limiting styling to many form elements.  The fact that the problem is with checkboxes would support that theory.

Because it runs alright in a browser It almost certainly points at Sharepoint not being able to handle the styling because it is following the old MS standards instead of the W3C standards.  AFAIK Sharepoint is loosely associated with Office which has a very limited ability to use standards compliant CSS.


Accepted Solution

pjenrow earned 0 total points
ID: 40720260
I finally came up with a method to get an iFrame with css and JavaScript functionality to run through a SharePoint portal.  Specifically, I set up an html page and created my tabbed interface with the ever useful JavaScript tabifier ( .  The tabifier renders the css, and JavaScript functions effect the interactivity without any problems.  I used a CEWP in the pages that I want to point to the page, and within the CEWP I used just a standard HTML iFrame tag.  Works great!

Author Closing Comment

ID: 40729299
The general view was that the problem with using an iFrame, or page view web part was related to a cross-domain security setting.  I don't believe this is the case with content within the same SharePoint site collection.  The problem was actually that SharePoint (at least 2010) is very particular about how CSS is added.  My workaround was based on JavaScript.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
alert before form submission 6 30
Remove greater than sign 3 42
Show banners that are blocked by Ad Muncher 10 46
Put glyphicon in my input button 4 25
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at Browse or search based on font properties or name to find a suitable font for…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now