Solved

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

Posted on 2015-02-08
7
363 Views
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.
0
Comment
Question by:pjenrow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 44

Expert Comment

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

Author Comment

by:pjenrow
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.
Example.zip
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
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.

Cd&
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pjenrow
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.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
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.

Cd&
0
 

Accepted Solution

by:
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 (http://www.barelyfitz.com/projects/tabber/) .  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!
0
 

Author Closing Comment

by:pjenrow
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
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 google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

696 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