5

I have content editor web part in which I am using iframe to display data from some other site.

The iframe code is pretty simple such as:

<iframe src="http://www.stackoverflow.com"></iframe>

Problem is sometimes SharePoint will remove the "src" from iframe. I noticed that it only happens when I try to Edit that page to make some other changes and then save it. So during loading of page when it is in Edit or Save mode it removes the "src" from iframe. And that too doesn't happen all the time but only sometimes. So the resulting iframe looks like this:

<iframe src=""></iframe>

Why is that?

0

The Content Editor Web Part is intended for adding HTML content to a Web Part Page, it is not designed to link to a Web site. If you need to link to a Web site, consider using the Page Viewer Web Part. -Microsoft- http://office.microsoft.com/en-us/windows-sharepoint-services-help/about-the-content-editor-web-part-HA001160897.aspx

9

In addition to Milind's answer: it is not good practice to put html directly into the CEWP just because you can. For one, it will only work on some kinds of pages. Web part pages are fine, wiki pages will chew the html. Secondly, it will be hard to maintain, since you will need to edit the web part itself every time you want to make a change.

As an alternative, if you want to use a CEWP to inject html onto a page, put the html code into a text file, upload that file to a document library (or better, to the Style Library of the site collection, so the site users cannot mess with it) and then reference that file in the CEWP link settings.

With this technique you can even use the same html on several different pages (or sub-sites) and if you need to change the underlying html you only need to touch one file.

  • After 8 months of playing around with SharePoint 2013, this is one of the best advice actions to take. I would only add that if you reference data from the text/html file, with javascript, load it all once the window is ready. By then, sharepoint is done loading/modifying the HTML on the page. – klewis Feb 20 '15 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.