Replace URL's on the Quicklaunch in Javascript

Here is some sample code:

while(document.getElementById('zz2_QuickLaunchMenu'+i) != null) 
{  
               var menu = document.getElementById('zz2_QuickLaunchMenu'+i); 
              //looks for the hyperlink tags using the quicklaunch tag 
               var hyperlinks = menu.getElementsByTagName('a');  
               hyperlinks[0].href = hyperlinks[0].href.replace(URL, URLToReplace);  //replaces the URL text 
               hyperlinks[0].target = "_blank";                            //allows for opening the link in a new window                
               i+=1;
 
}
This tag for the quicklaunch: zz2_QuickLaunchMenu you can find by right clicking on your list and looking for the quick launch menu.  It will probably include the name "QuickLaunchMenu" and some text in the same format as zz2_.  The code is pretty straightforward.  If you have any comments or questions let me know.  Have a very good weekend!

Re-posted from old blog.

Technorati Tags: ,,

Print | posted on Friday, February 22, 2008 5:00 PM

Feedback

# re: Replace URL's on the Quicklaunch in Javascript

Left by Rob (Maidstone) at 8/7/2008 5:13 AM
Gravatar Does this need to go into a content editor webpart on the page?

# re: Replace URL's on the Quicklaunch in Javascript

Left by MOSSLover at 8/8/2008 5:07 PM
Gravatar You could put it in a web part or embed it in the page or add it to a content editor web part. It's really one of those pick your poison type of things.

# re: Replace URL's on the Quicklaunch in Javascript

Left by Arun at 12/24/2008 5:03 AM
Gravatar Can it be done at run time , i want thing to be done during pacakage and deployment of a sharepoint site.

please comment ....

# re: Replace URL's on the Quicklaunch in Javascript

Left by Suresh at 12/25/2008 10:50 PM
Gravatar Hi

i think if we using this above javascript code to update on page,but not updating in actual source(from share point db).In each every time this script needs to be execute on page loading.

i need help to update the url only once to be exected ....


Please help me to come out with solutions.

# re: Replace URL's on the Quicklaunch in Javascript

Left by MOSSLover at 12/25/2008 10:58 PM
Gravatar Arun - you want to do this at the Page Load Event. Override the Page Load event in Javascript as seen at this link: http://blogit.create.pt/blogs/andrevala/archive/2007/12/16/WSS-Tip-_2300_19_3A00_-Using-JavaScript-in-Body-OnLoad-Event.aspx.
Suresh - You should add the Javascript code to a master page. That will allow you to use this code in multiple pages.

# re: Replace URL's on the Quicklaunch in Javascript

Left by Keno in rete at 5/19/2010 12:58 AM
Gravatar Thanks for info.

# re: Replace URL's on the Quicklaunch in Javascript

Left by flying at 6/18/2010 11:36 AM
Gravatar i like it very much thank you !

Your comment:





 
 

Copyright © MOSSLover

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski