How can you remove the # (anchor tag) from the URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 10:57 AM
We have knowledge articles that utilize anchor tags, however, we want to remove the # that is added to the URL when the user clicks on the bookmark links.
Current Result:
https://.service-now.com/sys_id=5eafb51537df79807cae27d2b3990e77d&table=kb_knowledge#TableOfContents
Desired Result:
https://.service-now.com/sys_id=5eafb51537df79807cae27d2b3990e77d&table=kb_knowledge
Thanks in advance for your help,
Jessica
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 09:25 PM
Hello,
How are the articles bookmarked? If you need to correct these bookmarks, navigate to sys_ui_bookmark table, locate all bookmarks related to your kb_knowledge with a # in it and you could update the URL in here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 10:17 PM
How are you making articles bookmarked ?
also can you share your widget code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 07:15 AM
Anchor tags are placed directly in the HTML of the KB Articles.
For example:
<p><span style="font-size: 12pt;">To apply for benefits, please contact your state's administrator (<a href="#SDIAdministrator" rel="nofollow">below</a>). Benefits are not automatic; if you do not apply, you will not receive benefits.</span></p>
Widget - Link field - This custom code was added by a previous vendor to remove the anchor tags (#) from appearing in the URL. However, it is not working as expected. When click on the link from the HTML above the page does not scroll to the current section in the article. We attempted to remove this code, but that resulted in the anchor tags to appear in the URL which is not what we want our end users to see.
function(scope, element, attrs) {
setTimeout(function(){
var el = $(element[0]);
$(el).find('*[href=\\#TableOfContents]').on('click', function() {
scope.scrollToTop();
});
},500);
setTimeout(function(){
$('a[href^="#"]').on('click', function(event) {
var target = $(this.getAttribute('href'));
if( target.length ) {
event.preventDefault();
$('.flex-grow').stop().animate({
scrollTop: target.offset().top - 200
}, 100);
}
});
},500);
}