none
SharePoint Anchor Tags

    질문

  • Trying to create a Wiki with Sharepoint using designer.  I enter the url in the properties window as /wiki/test.aspx#section-3 and save it.

    When I load the page on the site and click on the link it  rewrites the link for me as /wiki/test.aspx%23section-3 creating an invalid page error.

     

    How do I get Sharepoint not to mess with the URL's after they are entered directly, (a url manually entered should not be html encoded!).

     

    This is a very basic precept of hyper text markup language and should not require a workaround.  Weren't anchor tags part of the initial html spec back when no one knew what the internet was except for a few random geeks? Back when Mosaic (http://en.wikipedia.org/wiki/Mosaic_%28web_browser%29) rained supreme?

     


    Matthew Hazlett
    Clarity Computers
    http://www.devclarity.com/
    2011년 1월 1일 토요일 오후 11:31

답변

  • Here's a little workaround I have just wrote :

    <script type="text/javascript">
     setTimeout(Reload,2000);
     function Reload()
     {
      window.location.hash=self.document.location.hash.substring(1);
     }
    </script>
    

    Note 1 : Paste this code in the HTML of a "Content Editor Web Part".

    Note 2 : Page will scroll back and forth...

    • 답변으로 제안됨 arc_dev 2011년 8월 23일 화요일 오전 6:30
    • 답변으로 표시됨 Margriet BruggemanMVP 2012년 4월 9일 월요일 오전 9:22
    2011년 2월 7일 월요일 오후 3:54
  • Actually, you don’t have switch to HTML view to create a inpage hyperlink.

     

    Edit your publishing page and select some text. Now click “Insert/Link/From Address”. In the pop up window just type “/” for the “Address” field. Remove “/” from the URL field and add “#Chapter1” or equivalent value to “Bookmark”.

     

    Now you will be able to create an anchor to “#Chapter1”. Just select some other text in your page. Now click “Insert/Link/From Address”. In the pop up window just type “#Chapter1” for “Address”. Save and your inpage link will work.

     

    Indeed, if you add the Content Editor Web Part and the Javascript of fcorbeil the page will scroll up and down again.  JQuery may improve on this, and we could put the Javascript inside the page layout so editors do not have to do this plumbing work J

     

    wimdg@hotmail.com

    2012년 1월 30일 월요일 오전 11:24

모든 응답

  • Very strange it seems to call this js function

    function OpenPopUpPageWithTitle(url, callback, width, height,title)
    {ULSsa6:;
    	var fn=function ()
    	{ULSsa6:;
    		var dOpt={url: url, args: null, title: title, dialogReturnValueCallback: callback, width: width, height: height};
    		var dlg=SP.UI.ModalDialog.showModalDialog(dOpt);
    	};
    	var defd;
    	try
    	{
    		defd=typeof(SP.UI.ModalDialog.showModalDialog);
    	}
    	catch (e)
    	{
    		defd="undefined"
    	}
    	EnsureScript("SP.UI.Dialog.js", defd, fn);
    }
    
    What does a link have to do with a modal dialog?
    


    Matthew Hazlett
    Clarity Computers
    http://www.devclarity.com/
    2011년 1월 2일 일요일 오전 12:16
  • This problem is getting tiring:

    I had used the link maker [[test.aspx]] in the editor initally.  When I viewed the link in the designer it was a normal <A> tag. I modified the <A> tags properties in the designer but it kept changing back to the old <A> link code when I would save it. 

    So, I decided out of frustration to just delete the lines all together and manually type in the <A> link and save, this seemed to work!

     

    Now the links work right?...

    Hooray?

    Not so fast :-(

     

    The <A> links work perfactly, they load the page up perfactly.  The url is reported in the address bar perfactly.  So whats the problem?

    Aparently there is a javascript somwhere in core.js that makes the page jump to the top of the top of the document after the page loads.  So while the page loads correctly now, it dosn't matter because as soon as it finishes, it will jump to the top of the document.  Making the anchor tag useless.

     

    Maybe I should just nip it in the butt now and tell the powers that be that wordpress or joomla is a better solution for the corporate intranet, I am so fed up with this over engineered monstrosity.

     


    Matthew Hazlett
    Clarity Computers
    http://www.devclarity.com/
    2011년 1월 2일 일요일 오전 5:06
  • Trying to create a Wiki with Sharepoint using designer

    Could you please let me know the detailed steps? I had create an ASPX page in SharePoint Designer 2010 and I can insert hyperlink such as http://en.wikipedia.org/wiki/Nilambur#Educational_institutions with copy and paste or the Insert->hyperlink Ribbon button. The link works well.

     

    And I can edit or create a Wiki Page in browser interface and can copy and paste link without any issue.

    2011년 1월 3일 월요일 오전 1:54
    중재자
  • It only happens in Sharepoint 2010.

    1. Download 2010
    2. Create a Website / etc.
    3. Create 2 wiki pages of any name you want.
    4. Put 3 anchor tags in one file, Section 1, and make sure each tag is abut 25 lines from the previous tag (so they each look like they are n separate pages)
    5. in the second file put an A link to each section. Section 1

    Now view the file ad click on the different sections, after the page loads at the correct tag it goes to the toop of the document making the tag useless.

    2011년 1월 3일 월요일 오후 1:12
  • I have the same issue where anchored links are not working WITHIN SP2010 sites. I have been trying to track down a workaround for some time. Our clients are not happy that anchored links are not working on their SP 2010 publishing site pages.

    To test:

    1. I created a new 2010 publishing site collection in order to make sure this was a default SP 2010 bug and did basically the same steps as hazlema.
    2. Created a 2nd page with lots of content and created anchor tags so the page would need to scroll to the bottom.
    3. When you are on the page, and use the #bottom in the URL it works correctly.
    4. When you create a link from another page to go to Test-Page-2.aspx#bottom, it goes to the bottom at first, then the page automatically refreshes and pops back to the top of the page.

    This is a major bug, how can a simple HTML anchor tag not work properly within a SP site?

    Thanks

    2011년 1월 21일 금요일 오전 12:39
  • Yes, I am still waiting on my "MSDN Priority Support" on this one, its been a few weeks now.
    Matthew Hazlett
    Clarity Computers
    http://www.devclarity.com/
    2011년 1월 21일 금요일 오전 1:09
  • I can reproduce this, thanks for reporting and i have escalated this issue.

    BTW, i don't know this "MSDN Priority Support", part of my job is to take care of what we called "Managed case" posted by subscriber, but it is only for SharePoint 2007 currently.

    2011년 1월 21일 금요일 오전 4:46
    중재자
  • Any new activity on this, been over a week.  Anyway, we moved to another solution, we could not get this to work.
    Matthew Hazlett
    Clarity Computers
    http://www.devclarity.com/
    2011년 1월 29일 토요일 오후 8:45
  • Has anybody managed to find the answer for this? I  have the same issue where anchored links are not working with in SP2010 sites
    2011년 1월 31일 월요일 오후 12:11
  • I have the same problem here!  Any news from Microsoft?

    2011년 2월 7일 월요일 오후 12:48
  • Not a peep
    Matthew Hazlett
    Clarity Computers
    http://www.devclarity.com/
    2011년 2월 7일 월요일 오후 1:48
  • Here's a little workaround I have just wrote :

    <script type="text/javascript">
     setTimeout(Reload,2000);
     function Reload()
     {
      window.location.hash=self.document.location.hash.substring(1);
     }
    </script>
    

    Note 1 : Paste this code in the HTML of a "Content Editor Web Part".

    Note 2 : Page will scroll back and forth...

    • 답변으로 제안됨 arc_dev 2011년 8월 23일 화요일 오전 6:30
    • 답변으로 표시됨 Margriet BruggemanMVP 2012년 4월 9일 월요일 오전 9:22
    2011년 2월 7일 월요일 오후 3:54
  • Does anyone have an update on this? I just encountered the bounce to the top behaviour with our SP 2010 Wiki.

    Thanks

    2011년 6월 22일 수요일 오후 5:21
  • Is there any solution to this yet, both for wikis and publishing sites?

    2011년 8월 22일 월요일 오후 6:39
  • The solution provided by fcorbeil above is very elegant and easy to implement. I've dropped it into my page layout for my publishing site and it works like a charm. Thanks for sharing this solution, @fcorbeil :)
    2011년 8월 23일 화요일 오전 5:56
  • Here's an improved version:

    $(function() {
    	var fn = FixRibbonAndWorkspaceDimensions;
    	FixRibbonAndWorkspaceDimensions = function() {
    		var firstCall = !g_setWidthInited;
    		fn();
    		if (firstCall) 
    			window.location.hash = self.document.location.hash.substring(1);
    	}
    });
    It's using the jQuery "ready" event functionality, but if you don't have jQuery available, you can also use document.addEventListener / document.attachEvent (be sure to check which one exists) to attach to the "load" event.

    The issue here is that FixRibbonAndWorkspaceDimensions() creates the Ribbon and does some resizing, which causes the browser to scroll to the top of the page. This snippet ensures that right after, the browser scrolls to the anchor tag. It also ensures that this is being done only on the initial load of the page as FixRibbonAndWorkspaceDimensions() is also called later (e.g. upon resize).

     


    • 편집됨 PSchmiedel 2011년 8월 26일 금요일 오전 9:50 formatting
    2011년 8월 26일 금요일 오전 9:49
  • My problem is similar but I can't use the Javascript or JQuery solutions with my Gov't Canada client since it would violate the "No Javascript" rule for external facing websites.

    Does anyone have a solution for this yet that does not require Javascript?


    We the willing, led by the unknowing, are doing the impossible for the ungrateful. We have done so much, with so little, for so long, we are now qualified to do anything, with nothing." ~ Mother Teresa ~
    2011년 9월 16일 금요일 오후 6:16
  • Any update on the anchor tags?

    If I try fcorbeil's script, does anyone know where in the page layout the code goes?  Do I have to change any variables or does SharePoint and the browser understand everything in there.  Sorry, I'm a hardware engineer.  I'm already way out of the boat here.

    Thanks, Mike

    2011년 10월 28일 금요일 오전 5:18
  • This workaround worked for me: http://sharepointsearch.com/cs/blogs/sharepointblogs/archive/2007/10/31/using-named-anchors-in-sharepoint-wiki-pages.aspx
    2012년 1월 27일 금요일 오후 4:17
  • Actually, you don’t have switch to HTML view to create a inpage hyperlink.

     

    Edit your publishing page and select some text. Now click “Insert/Link/From Address”. In the pop up window just type “/” for the “Address” field. Remove “/” from the URL field and add “#Chapter1” or equivalent value to “Bookmark”.

     

    Now you will be able to create an anchor to “#Chapter1”. Just select some other text in your page. Now click “Insert/Link/From Address”. In the pop up window just type “#Chapter1” for “Address”. Save and your inpage link will work.

     

    Indeed, if you add the Content Editor Web Part and the Javascript of fcorbeil the page will scroll up and down again.  JQuery may improve on this, and we could put the Javascript inside the page layout so editors do not have to do this plumbing work J

     

    wimdg@hotmail.com

    2012년 1월 30일 월요일 오전 11:24
  • Wim De Groote's solution worked just fine for me.  It's very similar to the one laid out by ThoughtfulTech (see link below).  The only issue I have is that in both cases, the initial text that is bookmarked ends up looking like/being a link (blue, underlined text). 

    I need the bookmark or anchor point to be invisible (think "back to the top" links).  This is easily achieved by switching to HTML view and just inserting an anchor tag as you would normally, but I am trying to avoid the HTML view for the sake of my user base who is asking for this. They need a simple solution.  Am I out of luck? 

    http://mccoard.net/ThoughtfulTech/post/2011/05/11/Creating-a-Bookmark-(anchor)-link-in-SharePoint-2010.aspx

    2012년 2월 16일 목요일 오전 3:20
  • Hi all. I'm attempting to use the instructions provided via the ThoughtfulTech link.

    No problems creating the first link, or the target link (the anchor) for that matter. But when I select Link Tools and "Format" to add the bookmark, the bookmark field isn't there. I only have the URL and Description fields.

    Any idea why the bookmark field is missing? I'm running Sharepoint 2010.

    Thanks,

    Dan

    2012년 2월 28일 화요일 오후 9:51
  • I tried Wim De Groote's instructions.  My first bookmark worked, but the ones after that just bookmarked to the position of my first bookmark.  What am I doing wrong or is it a glitch?  Does the bookmark name need to not have any spaces?  So, can "Chapter1" be "Chapter 1"???

    Thanks.

    2012년 5월 9일 수요일 오후 8:15
  • The bookmark name cannot have any spaces and in some browsers is also case sensitive.
    2012년 5월 22일 화요일 오전 3:41
  • Hi all. I'm attempting to use the instructions provided via the ThoughtfulTech link.

    No problems creating the first link, or the target link (the anchor) for that matter. But when I select Link Tools and "Format" to add the bookmark, the bookmark field isn't there. I only have the URL and Description fields.

    Any idea why the bookmark field is missing? I'm running Sharepoint 2010.

    Thanks,

    Dan

    I have the same problem, the Bookmark field doesn't show up.

    Also using Sharepoint 2010.

    Ideas anyone?

    Thanks,

    dan

    2012년 6월 12일 화요일 오후 2:26
  • It also happens when you try to link to an anchor in wiki page hosted within Sharepoint365.
    2012년 11월 1일 목요일 오전 11:59
  • Re: This is a major bug, how can a simple HTML anchor tag not work properly within a SP site?

    Agreed!

    2012년 11월 1일 목요일 오후 12:00
  • for an anchor tag in enterprise wiki page to work, you need to create with steps in http://mccoard.net/ThoughtfulTech/post/2011/05/11/Creating-a-Bookmark-(anchor)-link-in-SharePoint-2010.aspx

    the resulting link looks like:

    Or looks like:

    2012년 11월 2일 금요일 오전 7:29
    중재자
  • without the customization fcorbeil suggest, if you put the address such as http://sharepointservername/sitepath/pagename.aspx#bookmarkname into address bar, you will most probabily goto the top of page instead of the book mark, however, fcorbeil's suggestion:run the script

    window.location.hash = self.document.location.hash.substring(1)

    after sharepoint's internal javascript finished will lead you to the bookmark.

    If the end user just press enter in the address bar will also work, that is, go to the bookmark.

    But click refresh button will load the page and run SharePoint's initialization javascript again, that is, go to the top of the page.


    2012년 11월 2일 금요일 오전 8:13
    중재자