?
Solved

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

Posted on 2015-02-08
7
Medium Priority
?
373 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Suggested Courses

764 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