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?

1 Answer 1


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 = "http://sharepoint.domain.com"
    $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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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