What are you talking about?
Last year I wrote a blogpost concerning the PathToSharePoint solution to parse html on a SharePoint page. That solution was great and was working really well. It wasn’t however working in SharePoint 2010.
They have released a new script, specifically for SharePoint 2010!
What is it ?
Say, you want to create your own hyperlink, with parameters (to prepopulate some fields for instance)
You can create a string in a calculated field that builds up your url using fields from your list.
That makes the solution very user friendly.
The script
<script type="text/javascript">
// Copyright (c) 2010 Christophe Humbert – Path to SharePoint
// Find all Web Parts in the page
var listWP=[],calWP=[],divs=document.getElementById(“MSO_ContentTable”).getElementsByTagName(“div”);
var count=divs.length;
for (i=0;i<count;i++) {
try {
if (divs[i].id.indexOf(“WebPartWPQ”)==0){
if (divs[i].innerHTML.indexOf(“ViewDefault_CalendarView”)>=0) {
// Calendars
calWP.push(divs[i].id);
}
else {
// Other Web Parts
listWP.push(divs[i].id);
}
}
}
catch(e){}
}
function TextToHTML(NodeSet, HTMLregexp) {
var CellContent = “”;
var i=0;
while (i < NodeSet.length){
try {
CellContent = NodeSet[i].innerText || NodeSet[i].textContent;
if (HTMLregexp.test(CellContent)) {NodeSet[i].innerHTML = CellContent;}
}
catch(err){}
i=i+1;
}
}
var regexpA = new RegExp(“\\s*<([a-zA-Z]*)(.|\\s)*/\\1?>\\s*$”);
var regexpTD = new RegExp(“^\\s*<([a-zA-Z]*)(.|\\s)*/\\1?>\\s*$”);
var WP = new Object;
function UpdateWP() {
if (calWP.length>0){
for (i=0;i<calWP.length;i++) {
WP=document.getElementById(calWP[i]);
if (WP.innerHTML.indexOf(“<\;”)>=0) {TextToHTML(WP.getElementsByTagName(“a”),regexpA);}
}
}
if (listWP.length>0){
for (i=0;i<listWP.length;i++) {
WP=document.getElementById(listWP[i]);
if (WP.innerHTML.indexOf(“<\;”)>=0) {TextToHTML(WP.getElementsByTagName(“td”),regexpTD);}
}
}
// Check every 200 ms, forever
setTimeout(“UpdateWP()”,200);
}
UpdateWP();
</script>
Don’t forget to delete the spaces in the <script> fields!!
Hullo! This is a great script (very useful!), thanks for providing it! Just a quick note, tho – it's not pasted properly onto the page. I had to hit the page source code and tease out the full thing.
That´s dont work… i receive a javascript error: "missing ;"
This script has some error, i receive the message: "Mising ;" I can´t find where…
Tiago, I noticed some troubles on my code posting. This should be resolved by now.
If not, you can always follow the link to PathToSharePoint:http://blog.pathtosharepoint.com/2010/06/16/html-calculated-column-solutions-for-sp-2010-part-iv/