I'm trying to add some JavaScript code to my o365 site which should be called everytime when the site is rendered and all the needed objects are initialized. So far I got to this, but still it doesn't work everytime:
<script type="text/javascript">
function theFunction()
{
if (document.getElementById("suiteBrandingIcon") != undefined)
{
// stuff, needed stuiteBradning icon
}
else
{
setTimeout(theFunction,200);
}
}
ExecuteAndRegisterBeginEndFunctions("sp.ui.pub.ribbon.js",null,null,theFunction);
</script>
I added this strange ExecuteAndRegisterBeginEndFunctions to render the site also after the Sharepoint ajaxdelta is called. I'm adding this code at the end of the masterpage before the body end tag.
Is there any sharepointOnRender handler or anything similar?