The CEWP is loading a HTML page stored in the Site Assets library. The HTML contains a few inputs and some Javascript.
Javascript is:
Function myInit(){
console.log("here");
Ctx = new SP.ClientContext();
}
ExecuteOrDelayUntilScriptLoaded(myInit, "sp.js")
Normally this code runs fine if you navigate to the page but not if you open the browser from a link directly to the page.
If the browser opens directly at the page the HTML controls load & so does sp.js but the myInit()
never gets fired.
============
Update:
I found even when using
Function myInit ( ) {
console.log ( " here1 " );
If (SP){
console.log ( " here2 " );
} else {
setTimeout (myInit, 400);
}
}
It will only output: here1 once