﻿/*
This script fixes some issues with AJAX on SharePoint publishing pages whereby
a partial postback will cause the title of the page (as rendered by the browser)
to beceom empty or even the name of the page layout used for the page.

This script needs to be referenced inside the <form> element of the page.
*/

var app = Sys.Application;
var origTitle = "";
app.add_init(SPCustomAppnInit);

function SPCustomAppnInit(sender) {
    origTitle = document.title;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (!prm.get_isInAsyncPostBack()) {
        prm.add_pageLoaded(SPCustomPageLoaded);
    }
}

function SPCustomPageLoaded(sender, args) {
    document.title = origTitle;
}
