.comment-link {margin-left:.6em;}

kHSw

Tuesday, November 30, 2004

Selecting the right Area when using the Sharepoint Navigation control

In our CMS project we are using the Sharepoint Navigation control (and other SPS controls) in our CMS pages.
We created an area (i've called it kHSw in this example) in Sharepoint with the name of our CMS website, our pages our displayed in Sharepoint using the connector. But whenever we browse to our CMS-website (it still looks like you are in Sharepoint), the Home area is selected instead of the area we've created.
There seems no easy way to change this, so I wrote some Javascript to deselected Home and select our area in the navigation bar.

I've changed the line <div class="ms-phnav1wrapper ms-navframe">
in our HTML to <div class="ms-phnav1wrapper ms-navframe" name="Intranet_Navbar" id="Intranet_Navbar" >

Here's the Javascript (I know, it could have been a little shorter, but at least this should be readable):
<script language="javascript">
var Area = "kHSw";

//Part1 - Select kHSw
var HTML = Intranet_Navbar.innerHTML;
var OC = HTML.indexOf(">" + Area + "<");
var TD1 = HTML.lastIndexOf("<TD ", OC);
TD1 = HTML.lastIndexOf("<TD ", TD1 - 1);
var TD2 = HTML.indexOf("</TD>", OC);
TD2 = HTML.indexOf("</TD>", TD2 + 1);
var tempHTML = HTML.substr(TD1, TD2 - TD1);
var replacedHTML = tempHTML.replace("Ms-phnavmidl1", "Ms-phnavmidl0Sel");
replacedHTML = replacedHTML.replace("Ms-phnavmidc1", "Ms-phnavmidc0Sel");
replacedHTML = replacedHTML.replace("Ms-phnavmidr1", "Ms-phnavmidr0Sel");
HTML = HTML.replace(tempHTML, replacedHTML);

//Part2 - Deselect Home
OC = HTML.indexOf(">Home<");
TD1 = HTML.lastIndexOf("<TD ", OC);
TD1 = HTML.lastIndexOf("<TD ", TD1 - 1);
TD2 = HTML.indexOf("</TD>", OC);
TD2 = HTML.indexOf("</TD>", TD2 + 2);
tempHTML = HTML.substr(TD1, TD2 - TD1);
replacedHTML = tempHTML.replace("Ms-phnavmidl0Sel", "Ms-phnavmidl1");
replacedHTML = replacedHTML.replace("Ms-phnavmidc0Sel", "Ms-phnavmidl1");
HTML = HTML.replace(tempHTML, replacedHTML);

//Write the replaced HTML
Intranet_Navbar.innerHTML = HTML;
</script>

0 Comments:

Post a Comment

<< Home


 
Stefanie Worm is het liefste vrouwtje van de wereld.
Melina is de liefste schatsie van de wereld (Erik De Maeyer).