SharePoint - Creating a Rotating Image Banner using JavaScript
Build a rotating image banner in SharePoint 2013 by reading a picture library with REST and swapping an img tag every 5 seconds.
Tag
Build a rotating image banner in SharePoint 2013 by reading a picture library with REST and swapping an img tag every 5 seconds.
A JavaScript client object model sample that fetches a list item attachment by file name.
var clientContext = SP.ClientContext.get_current();
var list = clientContext.get_web().get_lists().getByTitle("LISTNAME");
var listItem = list.getItemById(ID);
clientContext.load(listItem);
clientContext.load(listItem.get_attachmentFiles().getByFileName("FILENAME"));
clientContext.executeQueryAsync(Function.createDelegate(this, onSuccess), Function.createDelegate(this, onFailure));Read items from a SharePoint 2013 list with the REST API and jQuery, selecting only the fields you need.
var siteUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
jQuery.ajax({
url: siteUrl + "/_api/lists/getbytitle('ListTitle')/Items?$select=Title",
type: "GET",
headers: {Hide the page title on a SharePoint 2013 page with a small script added to the master page.
<script type="text/javascript">
function hidePageTitle() {
var elem = document.getElementById('pageTitle');
elem.style.display = 'none';
}
Override the HandleFolder function in a Script Editor web part so that folders in a document library open in a new window.
function HandleFolder(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {
var parts = new Array();
parts = c.toLowerCase().split('%2f');
c = c.replace('SitePages/Home.aspx', parts[1]);
window.open(c);
return false;A JSOM function that looks up a managed metadata term by name in a term set and writes name|id into a hidden field.
function GetFullTermStringByName(termName, termSetId, inputId) {
var clientContext = new SP.ClientContext.get_current();
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(clientContext);
var termStore = taxSession.getDefaultKeywordsTermStore();
var termSet = termStore.getTermSet(termSetId);
var terms = termSet.getAllTerms();A short tour of object oriented JavaScript: constructors, properties, prototype methods and single inheritance.
Add a Download a Copy button to each row of a document library using an extra column and a Script Editor web part.
Update custom profile properties as a non-admin user in SharePoint Online by calling the old user profile web service through SPServices.
Upload an attachment to a list item from a sandboxed visual web part by opening the AttachFile.aspx page in a modal dialog.
<script type="text/javascript">
function callback() {
alert('document uploaded');
}
function openPopup() {Escape single and double quotes in a string before an AJAX post, using a simple replace instead of encoding everything.
data.replace(/(['"])/g, "\\$1")One line of JavaScript that reloads the current page from the server.
document.location.reload(true);