Tuesday, September 24, 2013

jQuery spservices to get current user name for sharepoint site

Hi peeps,
In this post we are going to write a script which will give us the current user loggedin name for a sharepoint site using jQuery SPServices.
Below is the script:

// add the ref of jQuery file
<script type="text/javascript" src="/style library/jquery-1.7.2.js"></script>
// add the ref of jQuery SPServices file
<script type="text/javascript" src="/style library/jquery.SPServices-0.7.0.min.js"></script>
<script type="text/javascript">
var currentuserName = $().SPServices.SPGetCurrentUser({
   fieldName: "Title",
   debug: false
});
</script>


Hope this helps...
RELATED Post : How to display user information using ProfilePropertyLoader in sharepoint

Javascript Launch compose new email on button click

Hi Folks,
In this post we are going to see, how to launch compose new email page of your default mail client.
Below is the javascript which will do the trick. You just need to call this function on onclick property of the button present in your webpage.
In this example we will be adding the body of the mail as "{document url}" and subject as "My Subject"
Here we go..

<script type="text/javascript">
function mailThisMsg()
{
var recpt = ""
var subj = "My Subject"
var text = encodeURIComponent(document.URL)
var bcc = ""
var content = new Array()  
content[0] = "mailto:"
content[1] = recpt
content[2] = "?subject="
content[3] = subj
content[4] = "&body="
content[5] = text
content[6] = "&bcc="
content[7] = bcc
content = content.join("")
window.location = content
}
</script>


Hope this helps...

Javascript Hide recent changes section sharepoint 2010

Hi Folks,
In this post we are going to write a script which will hide Recently Modified Items from the Quick launch of sharepoint site.


Below is how we are going to acheive.

Add a HTML Form Web Part to any section of the page(preferably master page) and then add the below style.

<style>
.s4-recentchanges
{  
  display:none;
}
</style>

Below is the output without Recently Modified Items



Hope this helps...

JavaScript Back to Previous Page functionality on a button click

Hi Pals,
In this post we are going to see How to go back to previous page using Javascript on click of anchor button.

Below is the script which will take you to the previous page upon clicking on Back to previous page button.

<a href="#" onClick="history.go(-1)"> Back to Previous Page </a>

Popular Posts