7

I have a content editor webpart which references a HTML file

It has the below code

SCRIPT

<script>

function changeimageurl(imagepath){
    document.getElementById("slidecontainer").src=imagepath;
};

</script>

` HTML

<li onclick='changeimageurl("../gallery/_w/Slide1_JPG.jpg")' > "SOME LINK"</li>

This works fine when I directly go to page with url like

http://sitelink.com/sites/SUBSITE/webpages/gallery.aspx

But when I click on the quick launch on left side, it is loading page as

http://sitelink.com/sites/subsite/_layouts/15/start.aspx#/webpages/gallery.aspx

When the page loads like this, the changeimageurl function is undefined and the onclick is not working

Can I make the quick launch load the direct page instead of relative page with #/webpages ?

Or is there a work around?

0

2 Answers 2

8

You are noticing the URL with _layouts/15/start.aspx because the new feature Minimal Download Strategy is activated on your site.

To know more on how it works you can refer the below links

Introduction to MDS

What is start.aspx in SP 2013

If you don't want _layouts/15/start.aspx to be a part of your URL you need to deactivate Minimal Download Strategy feature available under Site Actions -> Manage Site Features

Note: Minimal Download Strategy is a new framework which is been written to increase the performance of the SharePoint site.

Source: Removing _layouts/15/start.aspx# from the URL on the address bar

UPDATE

As per comments from @wjervis, as an alternative to not disabling MDS functionality you can use RegisterModuleInit() method.

Ref: Register CSR Override on MDS enabled SP2013 site

1
  • 2
    Here's a link that mentions RegisterModuleInit(), the function that registers your scripts to work with MDS, if you want to add an alternative to just disabling MDS to your answer: blogs.msdn.microsoft.com/sridhara/2013/02/08/…
    – wjervis
    Commented Mar 7, 2017 at 11:59
7

You can disable the Minimal download strategy feature for the site, located under site settings > Manage site features.

That's what adding the extra string to your URL. ("/_layouts/15/start.aspx#").

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.