Solved

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

Posted on 2015-02-08
7
345 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
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

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.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

803 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