What I did (Javascript):
_spBodyOnLoadFunctionNames.push("OpenMyAd");
What was needed:
ExecuteOrDelayUntilScriptLoaded(OpenMyAd, "sp.ui.dialog.js");
Which does exactly what it says on the tin... It waits until the script is loaded and then executes what I told it to.
Credit goes to Sing Chan and his post.