Monday, October 3, 2011

Show only specific part of page – content editor web part

We all know that if we have requirement to view another page on specific page in SharePoint, we can use page viewer web part.

 However the limitation of page viewer web part is that you cannot view specific portion of a page. You have to view entire page.

 We can resolve this with the help of content editor web part. Well, this is not something which is related to completely with SharePoint.

This is a general HTML concept, however as content editor allows us to place HTML code inside it; I thought this can be a kind of a trick as well.

 Add content editor web part to a page and what I am going to do is I am going to show a post from our very own SharePointKings in a content editor web part I would like to show only a post not an entire page. I would like to show Social Tagging and Clouding Part -3.


So here is what I have written in content editor web part and follows is the end result.

<div style="width: 499px; height: 231px; overflow: hidden"><iframe src="http://www.sharepointkings.com/" scrolling="no" style="margin-top: -400px; width: 900px; height: 900px; margin-right: 100px"></iframe></div>



You need to make changes in left and top margins accordingly for a page that you would like to show in web part. However one very important note is that this directly takes a portion from a live page and hence any content that is changed on a source page needs to be monitored accordingly otherwise this web part would start showing something else as original source page changes.

4 comments:

Maarten said...

But your solution is not very secure. Most browsers will support the functionality of right-clicking inside an iframe and then opening the frame in a new location. I have solved this problem using the jQuery .load() function. Here you can specify a selector and only return the contents from that select.

SharePoint Kings said...

Hi Maarten,

Thank you for sharing this information. Appreciate your suggestion.

Anonymous said...

this helped a lot! thank you!

kay_dee said...

This helps. Thanks!




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com