Hi Paul:

   I have used _spBodyOnLoadFunctionNames.push quite lot in Content Editor web 
part without problem. Here is one example code:
http://littletalk.wordpress.com/2009/05/12/respond-to-sharepoint-survey-by-javascript/
But as I use JQuery as well, not sure if it matters.

Cheers

Ken


From: [email protected]
To: [email protected]
Date: Mon, 26 Oct 2009 16:01:45 +1100
Subject: RE: Javascript - add onload to _spBodyOnLoadFunctionNames



















I
haven’t added anything to the master. Is that the part I’m
missing?? J

 

I
was hoping to do all this on an ad hoc basis using a Content Editor web part.

 



Regards,



Paul

Online Developer, ICT

CEO Sydney



 





From: [email protected]
[mailto:[email protected]] On Behalf Of Steven Berry

Sent: Monday, 26 October 2009 3:53 PM

To: ozMOSS

Subject: RE: Javascript - add onload to _spBodyOnLoadFunctionNames





 

Hey Paul,

 

Have you tried lazy loading your
javascript function so im assuming the file is up in the masterpage and your
just calling from the body?

 

Such as: http://wonko.com/post/painless_javascript_lazy_loading_with_lazyload


 

Which has events fired off the
first instance? 

 

Else your functions should work:

 

function addLoadEvent(func)
{

  var oldonload = window.onload;

  if (typeof window.onload != 'function') {

    window.onload = func;

  } else {

    window.onload = function() {

      oldonload();

      func();

    }

  }

}







 

I’ve just tested this and
works ok on my WSS, loads 1st function and then runs second ok

 

 





From: Paul Noone [mailto:[email protected]]


Sent: Monday, 26 October 2009 3:44 PM

To: ozMOSS

Subject: Javascript - add onload to _spBodyOnLoadFunctionNames





 

Hi
all,

 

There
are two basic methods that I have found to run a js function (inside a Content
Editor web part) and neither are working for me.

 

I’ve
tried:

 

_spBodyOnLoadFunctionNames.push("myFunction");

 

function
myFunction() {

 
…

}

 

AND

 

function addLoadEvent(func)
{

  var oldonload = window.onload;

  if (typeof window.onload != 'function') {

    window.onload = func;

  } else {

    window.onload = function() {

      oldonload();

      func();

    }

  }

}

addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);

addLoadEvent(function() {

   /* more code to run on page load */

  }

);

 

Has anyone else successfully done this and can they provide a
working example?

 







This message contains confidential information and is intended
only for the individual named. If you are not the named addressee you should
not disseminate, distribute or copy this e-mail. Please notify the sender
immediately if you have received this e-mail by mistake and delete this e-mail
from your system. No responsibility is assumed by the company or its employee
to any other person for any loss or damage (whether caused by negligence or
not) arising from the use of the information and advice contained herein.
Finally, it is your responsibility to check any attachments for viruses and
defects before opening or sending them on.







                                          
_______________________________________________
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to