Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Wednesday, October 5, 2011

How to disable the RichTextBox in SharePoint

function disableRichTextBox(ctrlComments)
{
ctrlComments.disabled=true;
ctrlComments.readOnly=true;
var elm = document.getElementById(ctrlComments.id + "_toolbar");
if (elm) {elm.disabled=true; elm.readOnly = true;elm.style.display = 'none';}
elm = document.getElementById(ctrlComments.id + "_iframe");
if (elm) {elm.disabled=true; elm.readOnly = true;elm.style.display = 'none';}
ctrlComments.style.display = 'block';
}

Wednesday, August 31, 2011

SharePoint 2010 Ribbon Customization

http://makarandrkulkarni.blogspot.com/2010/01/sharepoint-2010-ribbon-customization_23.html

Friday, March 25, 2011

Hide List View Tool bar Items

function hideListViewToolbarItems()
{
var doc = document.getElementsByTagName('ie:menuitem');
for (var i = 0; i < doc.length; i++) {
var itm = doc[i];
if (itm.id.match('OpenInExplorer') != null)
{
var p = itm.parentNode;
p.removeChild(itm);
}

}
}

A few thoughts as to why it's not working...

1) Match for part of the text and leave off the "zz33_" as that part can be different for every page.

2) Don't delete the nodes, hide them

3) Make sure your code is loaded after the web part with the View dropdown (i.e. if using a Content Editor Web Part, move it under the list web part)

Reference:MSDN

Thursday, November 25, 2010

Disable the Anchor Tag Using JavaScript

function DisableTheAnchorTag()
{
var btnA= document.getElementById("name of the a tag");
if(btnA!= null)
{
btnA.onmouseover=function y(){this.style.cursor='default'}
btnA.setAttribute('onclick', "void(0);");
}
}

Tuesday, November 16, 2010

Get Current Logged On user using JavaScript

<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("GetCurrentLoggedOnUserName");
function GetCurrentLoggedOnUserName()
{
var Loginname = document.getElementById("zz8_Menu").innerHTML ;
var end = Loginname.indexOf("<");
var nameOnly = Loginname.substring(8, end);
alert(nameOnly);
}
</script>

Monday, November 15, 2010

Getting Query parameters using Javascript

<script language='JavaScript'>
// get the current URL
var url = window.location.toString();
//get the parameters
url.match(/\?(.+)$/);
var params = RegExp.$1;
// split up the query string and store in an
// associative array
var params = params.split("&");
var queryStringList = {};

for(var i=0;i {
var tmp = params[i].split("=");
queryStringList[tmp[0]] = unescape(tmp[1]);
}

// print all querystring in key value pairs
for(var i in queryStringList)
document.write(i+" = "+queryStringList[i]+"<br/>");
</script>