3

How Do I add this Javascript code to seattle.master page in SharePoint Designer for log off inactive user?

function LogOutInactive() {
    var idleInterval = setInterval(timerIncrement, 60000);

    $(this).mousemove(function (e) {
        idleTime = 0;
    });
    $(this).keypress(function (e) {
        idleTime = 0;
    });
}

function timerIncrement() {
    idleTime = idleTime + 1;
    if (idleTime > 9) {
    window.location = "http://[your site]/_layouts/15/SignOut.aspx";
}

Thanks,

  • 1
    Add it to a separate js file, and search for a .js reference in Seattle master page. Add reference to your js file just below that. – Gaurravs Dec 22 '15 at 14:31
  • Where is core.js or menu.js so that I add the .js reference to that? – jess370 Dec 22 '15 at 14:46
  • Yes, sequence matters – Gaurravs Dec 22 '15 at 15:49
3

The best is :

  • make a copy of your seattle.master (custom_seattle.master)
  • add your js reference in a scriptlink tag <SharePoint:ScriptLink Language="javascript" Localizable="false" Name="/_layouts/JS/myFile.js" runat="server"></SharePoint:ScriptLink> in the head of your masterpage
  • put your js file referenced in the masterpage in the Layout template of SharePoint (C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\JS\myfile.js) Do not forget TO NOT modify standard core files. If you want to apply a patch after, the risk is your modifications will be overridden

Regards,

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.