Good day, here I tested this code,

window.onload = function() { /* ваш код */ }; 

But, that he does not launch all events, is there something similar and more secure in work? I am still learning how to work with javascript. To force a command in javascript.

Closed due to the fact that the essence of the issue is incomprehensible by the participants of the Grundy , Alexey Shimansky , Cheg , Pavel Mayorov , Darth 7 Sep '17 at 13:26 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

This question was originally posted on the discussion forum, support and innovations for the site programmers.

  • one
    It is not clear what the problem is, explain in more detail - ishidex2

2 answers 2

window.onload code will be launched when the page is fully loaded, including all frames, objects and images. This will work in all cases, but most likely not the most cross-browser.

  • for example <script> window.onload = function () {<script src = "// f =" text / javascript "async> </ script>}; - Bor
  • This is not how it works. O_O. Inside the JS function, you are trying to execute HTML code. That's bullshit. You then need to look at connecting JS files through JS. Not via HTML. - Shmasya
  • How can I do this as an example? no, this is not exactly html, I try to run another script in the body of one script, this is not my idea, I saw one of the tips of one programmer, tried to check it in practice - Bor
  • window.onload = function () {var t = 'Hello, World!'; alert (t); } - Shmasya
  • An interesting window came out, and how to click on Hello, World! Click Ok. or close this event at random time, in continuation of this code window.onload = function () {var t = 'Hello, World!'; alert (t); What is there to register the click command and the button? - Bor

self-calling function

 (function(){ ваш код }()) 
  • thanks, I'll try it too - Bor