The current time is

Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Wednesday, May 28, 2008

Your window.onload may cause problems in Sharepoint !!

Looks very smart of Sharepoint designers to have the scripting functions run in a systematic organized way... Personally, I love organization... Makes things defined and in order, not just haphazardly..

Sharepoint works as follows...
onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();",


So if one would like to execute some function onload of a page... doing so:
window.onload = function()
would really cause him trouble since he'll overwrite the sharepoint function calls...

So the smart way of doing this is to use:

_spBodyOnLoadFunctionNames.push('myFunction_01');
_spBodyOnLoadFunctionNames.push('
mySecondFunction');

This is how sharepoint really works ;) :) So we're following their way and voilaaa...

Reference: http://blogs.tamtam.nl/mart/UsingWindowonloadInSharePointPages.aspx