SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

SharePoint 2010 allowed users to put JavaScript straight into the Quick Launch as a link.

Doing this in SharePoint 2013 causes an error when you try to save. I have some sites upgraded from 2010 that have kept their Quick Launch JavaScript but I can't edit or add more. Does anyone know a workaround?

share|improve this question

It is possible to do this with PowerShell. This does require the "Minimal Download Strategy" feature to be disabled on the site in question, otherwise you will receive an error when clicking on the link. Note, this might also be required for other links such as mailto: or file:// to work properly.

In the SharePoint Management Management shell you can do something similar to the following.

    #Add a new link
    $url = ""
    $spWeb = Get-SPWeb -Identity "$($Url)" -ErrorAction SilentlyContinue
    # Add link
    # The format is DisplayName, link, is external (true/false)
    $node = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Test Link", "javascript:alert('test alert')", $true)

    #Update existing link
    $spWeb = Get-SPWeb -Identity "$($Url)" -ErrorAction SilentlyContinue
    # Update link
    # Select the menu if necessary
    $selLink = $spWeb.Navigation.QuickLaunch | ? {$_.Title -eq "LinkName"}

    $selLink.Url = "javascript:alert('test')"


If you wanted to updated the Top Navigation, you can replace

$spWeb.Navigation.QuickLaunch with $spWeb.Navigation.TopNavigationBar

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.