SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Using named anchors in SharePoint Wiki pages

If you've ever tried to add a named anchor hyperlink in a MOSS/SharePoint Wiki page, you'll find that the SharePoint rich text editor does not support adding named anchors (hyperlinks to areas in the same HTML document) via the toolbar buttons (you'll get an error dialog). I was able to find one workaround here, but it didn't quite suit my needs. Following is possibly an easier workaround using root relative urls. To get this functionality, you first need to switch to source view and add some html code by hand.

Add Anchors

Click the source button to switch to HTML source view. Add your anchor wherever you need it in the source, for example:

<a id=”nameofanchorname=”nameofanchor></a>

When done adding anchors, click OK to go back to the rich text view.

Linking to Anchors

To create links to the anchors you just created, you can do this easily from the rich text toolbar by clicking on the Hyperlink button.

In the Hyperlink dialog, for the Address, specify the root relative URL for the page, in the following format:

/firstsubsite/secondsubsite/wiki page library name/Name of Wiki Page.aspx#nameofanchor

You can get this url by going out of edit mode on the page, and back to viewing the page in regular view mode.

  1. Copy the URL from the address bar
  2. Remove the first domain name part of the URL (e.g. http://domain.com)
  3. Add the named anchor portion (e.g. #nameofanchor) to the very end of the url.

 


Posted 10-31-2007 11:29 AM by adamtoth

Comments

Waldek Mastykarz wrote re: Using named anchors in SharePoint Wiki pages
on 11-01-2007 2:37 AM

You can use this feature on any control with an ID on it. So a <div id="foo" works as well as <a>.

adamtoth wrote re: Using named anchors in SharePoint Wiki pages
on 11-01-2007 11:31 AM

Good point, thanks.

Links (11/1/2007) « Steve Pietrek’s SharePoint Stuff wrote Links (11/1/2007) &laquo; Steve Pietrek&#8217;s SharePoint Stuff
on 11-01-2007 7:06 PM

Pingback from  Links (11/1/2007) &laquo; Steve Pietrek&#8217;s SharePoint Stuff

Jason Blake wrote re: Using named anchors in SharePoint Wiki pages
on 11-07-2007 2:30 PM

I've having some trouble implementing this. Could someone supply some snipets of html code?

adamtoth wrote re: Using named anchors in SharePoint Wiki pages
on 11-08-2007 8:15 PM

Hey Jason, can you post anything you've tried so far?

Pablo Picasso wrote re: Using named anchors in SharePoint Wiki pages
on 11-09-2007 2:18 AM

I have high hopes as I installed Telerik´s RADEDITOR. www.telerik.com/.../radeditor.aspx

That seems to be having a tool for creating anchor links - also other linking options are way better than in the native MOSS editor.

The lite-version is free for all MOSS users.

Jason Blake wrote re: Using named anchors in SharePoint Wiki pages
on 11-14-2007 4:07 PM

Actually after some experimentation I've found the following will work in MOSS 2007. The first few lines are the original hyperlink or the point from which to jump. The last few lines are further down on the webpage and designate the anchor.

<DIV>Jump to <A href="www.servername.com/.../SamplePage.aspx

.

.

.

.

.

<A id=Kanbay name=Kanbay></A>Kanbay Research Institute named blah, blah, blah inc. one of the top 10 firms in the United States among those favored by U.S. consumers.

SharePoint 2007 Link love: 11-19-2007, part four at Virtual Generations wrote SharePoint 2007 Link love: 11-19-2007, part four at Virtual Generations
on 11-19-2007 8:37 AM

Pingback from  SharePoint 2007 Link love: 11-19-2007, part four at  Virtual Generations

Jeahlo wrote re: Using named anchors in SharePoint Wiki pages
on 12-18-2007 5:42 PM

Thanks for the info regarding the HTML hacks, especially using the id attribute in the Div tag. I had used the name attribute in a link tag, but SharePoint Wiki turned all my headings blue and underlined. Using the id attribute in the Div tag, I can preserve the formatting I orignally had.

MG wrote re: Using named anchors in SharePoint Wiki pages
on 05-09-2008 2:05 PM

Yep... <a id=”nameofanchor” name=”nameofanchor”></a> did not work for me,

but remove the quotes and it does.

Should be:

<a id=nameofanchor name=nameofanchor></a>

Marcos wrote re: Using named anchors in SharePoint Wiki pages
on 05-29-2008 10:25 AM

Great info. It changed sharepoint wikis status to "usable".

Thanks!

icanbejason wrote re: Using named anchors in SharePoint Wiki pages
on 06-24-2008 3:50 PM

I have a question, as a total rookie.  When adding these anchors, do I include the font and align info within the tag, or do I just put it around the text that will show in the read-view.

ziera wrote re: Using named anchors in SharePoint Wiki pages
on 06-26-2008 10:53 PM

thanks! it works! i was trying hard on sharepoint and finally came across this.. thanks once a gain fro sharing. :)

BecsBouch wrote re: Using named anchors in SharePoint Wiki pages
on 08-08-2008 4:33 AM

Hoooray!!!!

IT WORKS!!!

I have been trying to write an anchor and link to anchor for literally the last day - i thought it was somehow the fact that i was inept (and putting it in html wrong as i am a complete novice) but then i found this blog - you are all brilliant! thanks for sharing!

time for a well deserved cup of tea...

jmac wrote re: Using named anchors in SharePoint Wiki pages
on 08-15-2008 11:45 AM

thanks for the tip. sharepoint wiki is now less painful but I definitely miss Confluence.

GillesGarcia wrote re: Using named anchors in SharePoint Wiki pages
on 09-09-2008 4:21 AM

Hi, Likely the most stupid question of the year, but i have to ask...

Is there a way to get the url of a web part.

I mean i'm composing pages using several Common Editor Web Parts and i'd like to be able to provide my own hand-made TOC. Thus i need to be able to point to each and every CEWP....  the tip to insert <A name=""> works fine (while we may expect something more sophisticated).

BUT as soon as i use some other web parts (e.g. Links) this trick doesn't work anymore....

Any idea how to "point to a web part"?  

Thanks !

Agiraffe wrote re: Using named anchors in SharePoint Wiki pages
on 11-11-2008 10:37 AM

Hi, now I am a complete newcomer to SharePoint and this is my first time doing anything but reading a wiki site. I was wondering, is it possible to integrate a search facility into my wiki site?

Burghthing wrote re: Using named anchors in SharePoint Wiki pages
on 11-18-2008 3:25 PM

>Pablo Picasso wrote:

>I have high hopes as I installed Telerik´s RADEDITOR.

I'm using that tool and unfortunately it does not work.  When you try to reference the bookmark it refers to the edit mode of the wiki page.  You can work around that by relative referencing I guess, but then you're back to editing the HTML again.

Dammika wrote re: Using named anchors in SharePoint Wiki pages
on 11-25-2008 10:23 AM

Div tag did not work for me I used SPAN tag and it works!!

example:

....<SPAN STYLE="color:#000000"> Anchor text to appear in this color</SPAN>........

I hope this would help some one some day like me!!!

Jacob wrote re: Using named anchors in SharePoint Wiki pages
on 01-15-2009 3:27 PM

How to create a named anchor. i.e. How to create an anchor that targets a specific location on a page.

the starting link should look like this:

<a href="#id_of_target_element">Click here to visit the target element</a>

the target/destination element should look like this:

<h3 id="id_of_target_element">You have arrived at the target elment</h3>

another example:

<p>Check out the following topics about bees:</p>

<a href="#behavior">Behavior patterns of bees</a>

<a href="#honeycomb">Masterpiece of Construction: The Honeycomb</a>

<a href="#hive">Take a look inside the Hive</a>

<h2 id="behavior">Fascinating Antics: Bee Behavior</h2>

<p>bla bla bla</p>

<h2 id="honeycomb">The Honeycomb: Nature's Masterpiece</h2>

<p>bla bla bla</p>

<h2 id="hive>A look inside of the Hive</h2>

<p>bla bla bla</p>

the value of the href="" attribute of the anchor tag, <a href="">, needs only to match the value of the id="" attribute of the target element. The target element can be anything, a heading, a paragraph, whatever. It just needs to have an id="" attribute.

Make sure that you prepend the value of anchor tag's href="" attribute with a hash mark (pound symbol) #.

this code:

<a href="#target_element">Click here to go to the target element</a>

will take you to this location:

<div id="target_element>blabla</div>

derdres wrote re: Using named anchors in SharePoint Wiki pages
on 04-21-2009 10:54 AM

I had some problems with this and so I hope this suggestion/clarification can help someone:

I think that all information is actually presented by adamtoth (original poster). A short html snippet would have been helpfull though. I will try to give one.

Example. Make an internal link to a H2 tag:

Create the heading with an id:

<H2 id=honeycomb>The Honeycomb: Nature's Masterpiece</H2>

Create the anchor tag that refers to the H2 element

<A href="intranet/.../here%20is%20a%20link%20to%20a%20subpage.aspx

The obtain the somewhat long and unmanageable href value follow the suggestion from adamtoth (original poster) on the top the page. It is what he calls the  "root relative URL". Notice that the id of the H2 tag is appended as suggested by adam.

/derdres

jio wrote re: Using named anchors in SharePoint Wiki pages
on 04-21-2009 10:55 AM

ji

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.