donderdag 12 november 2009

SharePoint – JavaScript OnLoad

Today I needed to fire some JavaScript code when a SharePoint page loaded. There are several ways to do this as far as I can tell, but there is only one way which I liked. After your JavaScript code you should include the following code:

_spBodyOnLoadFunctionNames.push("your method");

My customer needed a (pop-up) page that was printed and closed immediately after it was opened. I did this in the following way:

StringBuilder script = new StringBuilder();
script.Append("function onLoad()");
script.Append("  window.print();");
script.Append("  window.close();");

You should of course not forget to register your JavaScript. :-)

1 opmerking:

  1. Geen werving en selectiebureaus, enkel werkgevers! Solliciteer dus rechtstreeks bij de werkgever. Check jouw ict vacature!