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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.