Solved

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

Posted on 2015-02-08
7
327 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:pjenrow
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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)

744 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

12 Experts available now in Live!

Get 1:1 Help Now