Как добавить анкер гиперссылки в вики-странице SharePoint

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/55543

  •  10-12-2019
  •  | 
  •  

Вопрос

в страницах SharePoint (2010) Wiki достаточно легко, чтобы добавить гиперссылку, но как можно добавить гиперссылку ZORN без редактирования грязного HTML?

Вы можете увидеть здесь, что, хотя у меня есть ссылка и набрано в якоре в поле в закладке, он жалуется.Я могу спасти его, и, похоже, вспоминает то, что я там положил, но когда я пытаюсь использовать его, связываясь с якорем, он не прыгает (то есть <a href="#anchor1">jump</a> не работает).

Я посмотрел на этот учебник , но не работает.

Введите описание изображения здесь

Но реклама там на скриншоте говорит: «Вы можете сделать гиперссылки, которые прыгают прямо в номер в закладки» - хорошо, хорошо, ну, как мне это сделать?

Это было полезно?

Решение

I have managed to make this work by combining the information here and here.

  • To enable the bookmark functionality you need to get an admin to enable SharePoint Server Publishing Infrastructure feature on the site collection level and then the SharePoint Server Publishing feature must be activated on the site level.

    1. Start by selecting the text that you want the link to point to.
      Link selection

    2. Insert a new link From Address
      Insert new hyperlink

    3. Paste the current page address in the Address field Paste destination address

    4. Add your bookmark name (without the hash) Add bookmark name

    5. Select the text that should point to your bookmark and insert a new link From Address Insert new hyperlink

    6. Type the name of the destination bookmark (don't forget the hash) Add name of destination bookmark

    7. Save the page

Другие советы

The only way to do it is use an anchor tag in the code:

<a name="MyAnchor"></a>

Then add a hyperlink to the page the anchor is on, but include #MyAnchor:

http://mysite.com/wiki/page.aspx#MyAnchor

If there's a better way, let me know.

Ah, here is a way.

The idea is that the user using the wiki editor will create a new hyperlink and use a special token to denote an anchor. In my example, the token is /__

I chose that because the hyperlink has to start with something that the editor would accept - and it will accept a /. Also, because it is very rare to see a hyperlink with /__ anywhere in the string.

Thus, the user would use the regular wiki richtext editor, then use the "insert hyperlink" button, and specify a hyperlink like this:

/__myanchor

The function

This needs to be added in a Content Editor or in the master page somewhere. The function will look for that pattern and add a hyperlink name based on the specified link that was given, and then remove the false hyperlink (where the optional parameter specifies a # which causes it to be a hyperlink to that same page, which means it doesn't cause any navigation), or, if the parameter is specified, it will supply that url as a default.

function WikiLinks(defaulthyperlink){
    if(!defaulthyperlink)
          defaulthyperlink = "#";
    $(".ms-wikicontent a").each(function(){
        var thishref = $(this).attr('href');    
        if(thishref.indexOf('/__') >= 0){
            thisanchor = String(thishref).substring(3, String(thishref).length);            
            $(this).attr('name', thisanchor );
            $(this).attr('href',defaulthyperlink);
        }
    }); 
}

If you decide to use a different token, make sure the change the length in the thisanchor substring search.

[update]

The catch to this is that you must call the function after the UI is loaded. This means that the function works (like a charm) only within a single page. You can't use it to link to an anchor in another page because the linkage fires before the script gets to add the anchor name.

The wiki editor could make this easier :-)

This method works for me...

  1. Highlight a word in the header where you want to insert an anchor; then copy the word
  2. Press Ctrl-K. In my instance default text appears in the address field "/site/site/", click OK to accept the default
  3. You'll notice that a Link Tools ribbon appears. Paste the anchor name into the anchor field
  4. Go to your link text and highlight it; then insert a link "from address." Add "#" and paste again.

I have no idea if this will work in your case. Step 2 is weird. But it's the only way that I can invoke the "link tools" ribbon. Too bad this isn't part of the Link options from the get go.

[[EDIT: I didn't notice this before but SharePoint inserts the anchor/id AND a href link and there's nothing you can do about it except edit the HTML so my answer isn't much of a solution, unfortuntately.]]

To jump from 'Heading 1' to 'Section 1' on the same wiki page:

Highlight 'Heading 1', insert link 'from address' Text to Display: Heading 1 Address: #Section 1 click ok

then..

Highlight 'Section 1', insert link 'from address' Text to Display: Section 1 Address: # click ok

Highlight 'Section 1' again In Bookmark (in link tab) write: Section 1

Save page.

The way I found to create a link to a section (specific heading) on another Wiki page, is as follows:

1) Copy the URL (Ctrl-C) of the Wiki page (to have it ready to do the next step).

2) Create your link on the Wiki page by selecting the heading you wish to link to, such as: Section 2. Then click on the ribbon to insert link, From Address, and paste in the URL of the active Wiki page.

3) Click on the link you just created, and the LINK tab should appear.

4) Enter the Bookmark you want to use, such as: 02

5) Save the page or "Check-in" the page (if your site is using a Workflow process).

6) Go to your other page to create your new link to the Bookmark you just created and click to edit the page.

7) Enter or select the text you want to make your link to, and on the Insert tab, select Link - From Address, and paste the URL of the page you want to link to the specific bookmark (Section 2, for example).

8) At the end of the pasted URL in the link, just add the bookmark reference of that Section 2 with hashtag '#' prefix, which was created on the other Wiki page, in this example: #02. The link should look something like this: https:/mysharepoint/wiki/Pages/Instruction%20Guidelines%20for%20MDO.aspx#02

9) As an option, you can add in the Description box (on the Link tab) the title of the text heading (such as: Section 2). This will create a tooltip on the page when a user hovers over the link to click.

9) Save your page, and test the link. It should go directly to the other Wiki page and to the exact Bookmark for Section 2 (on that page).

The most voted answer has the disadvantage of creating a link on each link target that brings you back to the top of the page. I think it better to do as follows :

  1. Start by selecting the text that you want the link to point to.

• Insert a new link From Address

enter image description here

  1. In the Address field put in the anchor id (starting with a #)

• This, in effect, creates a link to itself meaning that when a user clicks on the header that is not a link destination, nothing will happen.

enter image description here

  1. In the Link definition, add your bookmark name (without the hash)

enter image description here

  1. Select the text that should point to your bookmark and insert a new link From Address

enter image description here

  1. In the Address: field type the name of the destination bookmark (don't forget the hash) enter image description here

This is a rather old post, but hopefully this will help someone else in the future.

In regards to intra-page hyperlinking in SharePoint 2010, I found it is easiest to do through MS Word with book marks, and hyperlinks.

Highlight destination, click Insert> Bookmark. Label Bookmark and hit add. Then highlight your source (what you want to click on to take you to your destination bookmark), click insert> hyperlink> Place in this document > Select your bookmark.

When you copy and paste this into SharePoint 2010, it will work, or at least has for me.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top