locked
SharePoint 2010 Content Editor Webpart inside Anchor Tags RRS feed

  • Question

  • Hi,

    I have an issue placing anchor tag inside Content editor webpart. I am looking for Named Anchors.

    Example:

    <A href="#Test">First</A>


    <div id=Test></div>

    And this as the anchor: When i click the  Test link , the cursor moved to div in normal html page.

    but content editor it is prefixing the current url , not moving to div tag.

    Could you please help here, how to do it.


    DVGR, SharePoint Developer

    • Moved by star.wars Thursday, April 3, 2014 1:55 AM
    Wednesday, April 2, 2014 12:41 PM

Answers

All replies

  • If you want, you can save your HTML as an HTML page and put it inside the content link of a CEWP.

    Andy Wessendorf SharePoint Developer II | Rackspace andy.wessendorf@rackspace.com

    Wednesday, April 2, 2014 2:29 PM
  • Hi DVGR,

    I tested the code in a wiki page (http://sp/SitePages/How%20To%20Use%20This%20Library.aspx) within my SharePoint 2010 environment (version 14.0.6126.5000), and it worked, you may check the code again in a test page with long article, or check if you can install CU patch for your SharePoint.

    <A href="#end">Go to end</A> 
    ......
    ......
    ......
    <div id="end"></div>

    Thanks,
    Daniel Yang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Daniel Yang
    TechNet Community Support

    Thursday, April 3, 2014 7:30 AM
  • Thanks Daniel for your response.

    with in page named anchor tags working fine. if the same conent is in Content editor webpart, it is not working.

    <A href="#end">Go to end</A>
    ......
    ......
    ......
    <div id="end"></div>

    for the above expample, when we mention #end, it comes as http://rootsiteurl/end . It is appending the root site url. This is my issue.

    Is there any way to remove the url in Content editor webpart.


    DVGR, SharePoint Developer

    Monday, April 7, 2014 11:42 AM
  • Hi ,

    Not sure if I understand correctly, could you share a screenshot about this issue with us?

    When I put the anchor tags (above <a> and <div>) within the content editor web part, it still works.

    If you mean you want to remove the url from web part, you can click url and then in "Link Tools" ribbon tab to remove link, or edit content editor web part and click "HTML->Edit HTML source" to remove url.

    http://www.sharepoint-insight.com/2010/07/19/how-to-edit-source-in-sharepoint-2010-content-editor-web-part-cewp/

    Thanks


    Daniel Yang
    TechNet Community Support

    • Marked as answer by star.wars Sunday, April 13, 2014 3:39 PM
    Tuesday, April 8, 2014 9:01 AM
  • the important thing here is that you need to add the link via HTML source window to Content editor web part (in the ribbon Format text > Html), not from WYSIWYG editor mode.

    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com


    • Edited by sadomovalexMVP Tuesday, April 8, 2014 10:10 AM .
    • Marked as answer by star.wars Sunday, April 13, 2014 3:39 PM
    Tuesday, April 8, 2014 10:09 AM
  • Hi ,

    In My Form, Rich text Editor is there. I have added below text inside Richtext.

    <A href="#FirstLink">First</A>

    ;

    ;

    ;

    ;

    ;

    ;

    <A id="FirstLink">First</A>

    When click ok button for the rich text editor webpage dilag the NamedAnchor tag is appended like below

    <A href="http://<rootsite>/#FirstLink">First</A>

    Is there any chance to avoid to append root url to named anchor tag?


    DVGR, SharePoint Developer



    • Edited by DVGR Monday, April 28, 2014 4:30 AM
    Monday, April 14, 2014 6:29 AM