SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a some default SharePoint complicated javascript function and I'm not sure how to override it, replace it.

In gerenal i know how to replace the functions, so that your implementation is called instead of the default implementation, but i dont know exactly how to do it for it.

So this script is very large i will post just small piece for illustration, the whole sciprt you can find in /layouts/navresizer.js

This is what i have to override:

Microsoft.Office.Server.Ajax.NavResizer.prototype = {
$20: function ($p0) {
    if (this.$1E) {
$21: function ($p0) {
    var $0 = $;
    this.$1F = ($0 === this.$A);
    if (this.$1F || $0 === this.$B) {
        this.$1E = $0;
        this.$18 = $p0.clientX;
        this.$19 = $p0.clientY;
        Sys.UI.DomEvent.removeHandler(this.$1E, 'mousedown', this.$12);
        var $1 = document.body; Sys.UI.DomEvent.addHandler($1, 'mouseup', this.$13);
        Sys.UI.DomEvent.addHandler($1, 'mousemove', this.$14);
        $ = (this.$1F) ? 'e-resize' : 'n-resize';
        this.$1A = this.get_$42();
        this.$1B = this.get_$43();
        Sys.UI.DomEvent.addHandler($1, 'selectstart', this.$15);
$22: function ($p0) {
    var $0 = document.body;
    Sys.UI.DomEvent.removeHandler($0, 'mouseup', this.$13);
    Sys.UI.DomEvent.removeHandler($0, 'mousemove', this.$14);
    Sys.UI.DomEvent.addHandler($0, 'selectstart', this.$15); 
    $ = 'default';
    Sys.UI.DomEvent.addHandler(this.$1E, 'mousedown', this.$12);
    this.$1E = null;
$23: function ($p0) {
$24: function ($p0) {
get_$25: function () {
    ULS4S1: ;
    if (this.$10) { return this.$C; }
    else { return $get('LeftNavigationAreaCell'); } 
$26: function () {
    ULS4S1: ;
    if (!Microsoft.Office.Server.Ajax.NavResizer.$5F(this.get_$25())) {
        var $0 = Microsoft.Office.Server.Ajax.NavResizer.$50(this.get_$25()) + this.$31;
        if ($0 > this.get_$42()) { this.set_$44(this.set_$42(this.$27($0))); this.$30(); } 
$27: function ($p0) {
    if ($p0 > this.get_$2B()) { $p0 = this.get_$2B(); }
    if ($p0 < this.get_$29()) { $p0 = this.get_$29(); }
    return $p0;
}, $28: function ($p0) {
    if ($p0 < this.get_$2C()) { $p0 = this.get_$2C(); }
    return $p0;
get_$29: function () {
    ULS4S1: ;
    return this.$1D;
} .........

Basically it is one of those functions: but they are all comma seperated so i dont know if i can override one of them seperatly.

So prolly i have to override everything.

But because it is that complicated i dont know how to override it, could anyone give me an idea how to do it?

share|improve this question
Wondering what is your goal... – Steve B Oct 12 '12 at 12:42
i just need to modify some value – Shkipper Oct 12 '12 at 12:45
re-writing a large chunk of Microsoft's core code is a drastic step - I'm sure there is an easier way to accomplish your requirement. – Derek Gusoff Oct 12 '12 at 13:16

Overriding sharepoint Out of the box scripts will put your farm in a unsupported state for upgrading to vnext.

You can create a mapped folder and create a new script with new functions and then call those functions wherever you need them.

share|improve this answer

Levalencia is right.. you shouldn't modify out of the box scripts.

However, it is perfectly fine to include scripts of your own. I would suggest creating a /layouts/navresizer-custom.js file, put your overrides there, and include it on your pages.

You can target which methods you would like to override simply by re-declaring them. For example, if you want to replae the $20 function, you would include the following in your custom.js:

Microsoft.Office.Server.Ajax.NavResizer.prototype.$20 = function() {
    // do stuff
share|improve this answer
normally those scripts are on demand, but when i do that it will always load mine and slow the perfromance. And this also means that my script will be overwritten because it is executed first and than the one on demand. What you also give as an example shows that i will override both of the functions i think. – Shkipper Oct 12 '12 at 14:25
up vote 0 down vote accepted

I could not find a good way to override this Javascript function, so i solved my solution by other method.

I think it is not really possible to override it or atleast i didnt succeed in it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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