This question has already been answered:

This is the code that makes third-party scripts and events work, but it doesn't always work, is there anything better than this?

<body onload="dosmth()"> <script type="text/javascript"> function dosmth() { <script src="......</script> } </script> 

Reported as a duplicate at Grundy. javascript 5 Sep '17 at 6:35 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • Are there any other forced launches in javascript language? - Bor
  • To be honest, this code is stalling, loading is loading and can not start another event, the page reacts to processes as it were, but, .. even the process does not start, or it may be a third-party script that is embedded in the body of the working script - Bor
  • Is the script already uploaded to the page? Why do you load it in another script? Do you need some specific event to work on an element from another script? - emre
  • yes, just to make another script work, how to do it correctly? it does not need to be inserted into the body of the script that will trigger the event? Look at an example, for example, some kind of "left script" that needs to be run using this <script type = "text / javascript"> function funonload () {} window.onload = funonload; </ script> - Bor
  • Guys, I'll come up later, I went to the kitchen later, accomplish your goal. - Bor

1 answer 1

If we are talking about the browser like this.

 <script type="text/javascript"> function funonload() { // } window.onload = funonload; </script> 

From the window object, it will always be called.

  • Thanks, but I need to give a kick to a third-party script. - Bor
  • Now I’ll put in a script instead of a link, try it thanks - Bor
  • I do not understand what the problem is. Even if the script is third-party loading it just has to be earlier than the call to window.onload. - Philip Pilipchuk
  • Guys, I'll come up later, I went to the kitchen later, accomplish your goal. - Bor