0

I'm trying to add a jQueryt block to oslo master page on spo 2013. check out, make changes and save, but no apparent impact. Am I placing javascript in the wrong place? do I need to do any additional steps. I'm using spd 2013.

Basically I want to add some code to keep all users except those with full control out of all pages except the site pages. Possible? if anybody is doing anything like this please share.

I'm placing this code right above the (/SharePoint:SharePointForm) tag close at the tail end of the master page

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">

<script>
alert("wtf");   

$(document).ready(function () { 

var currentUser;
// Ensure that the SP.js is loaded
if (SP.ClientContext != null) {
  SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
}
else {
  SP.SOD.executeFunc('sp.js', null, getCurrentUser);
}

function getCurrentUser() {
  var context = new SP.ClientContext.get_current();
  var web = context.get_web();
  currentUser = web.get_currentUser();
  context.load(currentUser);
  context.executeQueryAsync(onSuccessMethod, onRequestFail);
}

function onSuccessMethod(sender, args) {
  var account = currentUser.get_loginName();
  var currentUserAccount = account.substring(account.indexOf("|") + 1);
  alert(currentUserAccount);
}
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
  alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
}

});

</script>
1

It depends on the javascript that you have inserted.

Not all javascript placed in the head takes effect if it jQuery for instance. Try placing the javascript block at the bottom of the masterpage, just before the closing form tag.

If that doesn't do any changes, check if you need to publish the masterpage or something similar.

Also check if the javascript throws any errors using WebDeveloper (F12, IE) or Firebug (F12, FireFox add-on).

  • above the (/SharePoint:SharePointForm) tag close does not seem produce F12 errors, but does nothing. Might be that alerts don't work from the master? How exactly would you pubish? I checked in in and then out. – Hell.Bent Sep 6 '13 at 12:48
  • @cyberpine It seems odd that the alert doesn't trigger. A long shot would be to add type="text/javascript" to the <script> tag - <script type="text/javascript">. If it still doesn't trigger, try to remove the rest of the javascript so only the alert is left. Eliminate until it works, then take it from there. – user2536 Sep 6 '13 at 12:56
  • treid that, no luck. I must be missing some obvious Publishing or Site definition step. It's on o365/spo and i'm using SPD 2013. It's definitely the oslo master, but maybe it uses a copy?? – Hell.Bent Sep 6 '13 at 13:12
  • Anybody know what might be going on??? the date on the file is changing, but no new versions. Is there an approval pending I can't find? – Hell.Bent Sep 6 '13 at 21:03
0

Try turning off MDS (minimal download strategy). This sometimes causes weird behavior with scripts.

Your Answer

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

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