1

I have embedded a javascript on a page using Script Editor. The code do following.

$(document).ready(function () { 
    ExecuteOrDelayUntilScriptLoaded(loadConstants, "sp.js"); 
});


function loadConstants(){
   var context = SP.ClientContext.get_current();
   var web = context.get_web();
   context.load(web);
   context.executeQueryAsync(function(){
      console.log("success");
      $("#weburl").text(web.get_url());
      JSRequest.EnsureSetup();
      $("#fileurl").text(JSRequest.QueryString["uri"]);
   }, function(){
      console.log("failed");
   });
}

However the code doesn't work if the page running with MDS (i.g. the page URL is in /_layouts/15/start.aspx#/...)

If I remove the MDS url, it work fine.

Any idea how can i make my code work instead of disable MDS.

Thanks.

Jason Chan
  • 69
  • 10
  • If you activate MDS again, does it work? I'm not sure how MDS works and how/when it caches the site but if you can figure it out, you should be able to have your script added in the sites cache. – Christoffer Jan 26 '17 at 07:35
  • It doesn't not work even I enable MDS again – Jason Chan Jan 26 '17 at 07:43
  • https://blogs.technet.microsoft.com/sharepointdevelopersupport/2013/02/08/register-csr-override-on-mds-enabled-sharepoint-2013-site/ – Christoffer Jan 26 '17 at 08:15
  • http://sharepoint.stackexchange.com/questions/165150/issues-with-minimal-download-strategy-and-spbodyonloadfunctionnames-push – Christoffer Jan 26 '17 at 08:16

0 Answers0