I want to do something like document.currentScript.onload = function(){alert(0)};. Basically, executing some code after the current script is done executing. How would you do that?
Note that this is an inline script. I want to set the onload handler only under certain conditions that can be known during the execution of current script only.
What I have tried:
- The snippet above. This did not work and my guess is that you cannot set an onload handler on a currently executing script. My reasoning may be wrong though.
- document.write('\x3cscript>alert(0);\x3c/script>');. My hope was that the content of- document.writewould execute after the current script has finished execution. However, it seems that the content is executing as soon as it is written on the page stream.
 
    