Search Results page as an IFRAME inside another page

sharepoint_only_logoThere might be scenarios where the search center is configured in a different site collection but the client wants the search results inside the current context. In some cases the search center might not have the required branding.

For those unlikely & awkward scenarios, below is a dirty hack.

Here we edit the actual results page by adding custom CSS & JS codes which will trigger only when the page is opened inside an IFRAME. Then inside the actual site collection, we create a page (searchholder.aspx) & add a CE web part to hold this IFRAME. Here the searchholder.aspx also has to do additional work like passing on the search keyword to the actual results page present inside the IFRAME.

 

var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split(‘&’),
sParameterName,
i;
for (i = 0; i 0) {
var newheight = jQuery(‘#’+id).contents().find(“#Result”).height();
newheight = newheight + 200;
jQuery(‘#’+id).attr(‘height’, newheight);
}
}

jQuery(document).ready(function() {
// Try to change the iframe size every 2 seconds
setInterval(function() {
ResizeIframeFromParent(‘iframe_search’);
}, 2000);
});

 

Now inside the actual results.aspx add below inside a CE web part:

/_layouts/15/abg.onehrportal/js/jquery-2.1.1.js

$(document).ready(function()
{

var isInIframe = (window.location != window.parent.location) ? true : false;
if(isInIframe)
{
$(“#s4-ribbonrow”).hide();
$(“#suiteBar”).hide();
$(“#searchIcon”).hide();
var newHtml = “”;
$(“head”).append(newHtml);
}
});

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: