Forum Discussion

nnmpriem's avatar
nnmpriem
Copper Contributor
Jul 23, 2019

Create a navigation heading node without hyperlink

I'm trying to create a navigation node through code using either REST directly or PNP that is just a heading without a hyperlink, but am unable to. 

Does anyone have a code sample for just creating Headings to navigation elements?

  • paulpascha's avatar
    paulpascha
    Bronze Contributor

    Hi Mark,

    I have been struggling with this too in the past. The only workaround I know about is passing "javascript:return false;" as the URL for you navigation node. This effectively doesn't take user's to another location when navigation node is clicked, but the "hand icon" still appears when hovering over the node (this is not the case with a "real" Heading)

    Server-side this was controlled by setting property bag values on the SPNavigationNode (navigationNode.Properties["BlankUrl"] = "True"), but setting these is not available through remote API's.

    Hope this helps

    • nnmpriem's avatar
      nnmpriem
      Copper Contributor

      Thanks Paul! This is unfortunate. I'll try your workaround to see if it still works!

      • paulpascha's avatar
        paulpascha
        Bronze Contributor

        Please note the TechCommunity text editor encoded the URL you should use, I'm unable to find out how to let it render properly but there should be a colon ( : ) between "javascript" and "return true;"

Resources