Friday, September 15, 2017

Custom Search in Masterpage (sharepoint)

1.Place following code in masterpage at the place of Search control

<div id="divtoload">

<input type="text" id="txtKeyword"/><input type="button" onClick="parent.location=searchfn()" style="width:30px !important; height:20px; background: url(/sites/dms/Style%20Library/Images/nd_magglasssearch.png)" />

</div>


2. place script on head tag of master page:
Here: site: "http://spserver:1234"

<script type="text/javascript">
function searchfn()
{
var ss = document.getElementById("txtKeyword").value;
if(ss =='')
{
alert('Plese enter search keyword');
return window.location;
}
else
{
var url = "http://spserver:1234/sites/search/results.aspx?k="
var url1 = url.concat(ss);
return url1;
}
}
</script>​

No comments:

Post a Comment

Creating Provider hosted app (sharepoint online) with local hosted IIS

The Pre-requires are as follows. 1. Office 365 Subscription 2. Visual Studio 2015 (Professional/Community/Enterprise Edition) With t...