I wanted a way to capture links to sites in my SharePoint link list, but it's kind of a pain to copy the url, open my list, create a new item, paste…etc.
Here's the solution I came up with.
First open the site in designer and create a new form for entries in the link list. I just copied the newform.aspx and renamed it newsetvalueform.aspx
You can get the script in a text file from the downloads over on the My Local Broadband website: here
Now in the main content placeholder, right before the close of the content tag, put this JavaScript in place:
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("fillDefaultValues");
function fillDefaultValues()
{
var qs = location.search.substring(1, location.search.length);
var args = qs.split("&");
var vals = new Object();
for (var i=0; i < args.length; i++)
{
var nameVal = args[i].split("=");
var temp = unescape(nameVal[1]).split('+');
nameVal[1] = temp.join(' ');
nameVal[0]=nameVal[0].toLowerCase();
setTextFromFieldName(nameVal[0],nameVal[1]);
}
}
function getTagFromIdentifierAndTitle(tagName, identifier, title)
{
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++)
{
//alert("Found tag: " + tagName + "tag " + i + " of " + tags.length + " title: " + tags[i].title.toLowerCase());
var tempString = tags[i].id;
if (tags[i].title.toLowerCase() == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len))
{
return tags[i];
}
}
return null;
}
function setTextFromFieldName(fieldName, value)
{
var found=false;
if(!found)
{
theInput = getTagFromIdentifierAndTitle("textarea","",fieldName);
found = setValue(theInput,value);
}
if(!found)
{
var theInput = getTagFromIdentifierAndTitle("input","",fieldName);
found = setValue(theInput,value);
}
}
function setValue(inputField,value)
{
if (inputField != null)
{
inputField.value=value;
return true;
}
return false;
}
</script>
Save your custom file.
Now Create a favorite that points to:
javascript:function%20addlink(){t=document.title;u=escape(location.href);var%20q='http://www.intranoggin.com/Lists/Links/NewSetValuesForm.aspx?url='+u+'&description='+t;};%20addlink();
Make sure you replace www.intranoggin.com with the url of the site holding your link list.
You may need to actually go to where your favorites are stored, create a new shortcut to a web site, then go to the shortcut's properties and enter that bit of javascript.