in my Javascript code I load a page and then I would like to perform some functions. I tried to use solutions such as window.onload, but this happens after my html is loaded (blank page with only JS), I need a function to execute after loading the page that I am loading. I am using this code:
window.onload
this.document.location.href = myurl;
And after these loads, I would like to call some function. Is there any way to do this? Thanks
EDIT:
I cannot edit the source code of the landing page.
When you change the value document.location.href, you are essentially doing a redirection.
document.location.href
, , , xhr , , , , , .. , .. script, .
: , - - , , , . , , iframe, , , -
'window.onload = myFunction() {...}' , .
this.document.location.href , , onload- script . , document.location = myUrl . Document-API Mozilla
window.load leaves forever, because he is waiting for the loading of all the images and assets on the page.
window.load
It seems that the best solution for you would be to ask you to complete a document download. Here is a simple example:
(function poll(){ if(document.readyState === "complete" { // Your code here } else setTimeout(poll,500); })();
Source: https://habr.com/ru/post/1543791/More articles:bottom padding on scroll height fixed div is ignored in firefox - htmlHow to set focus on a list item? - c #How to access argv and argc in swift? - swiftGet the "up" side of the SCNNode from the orientation - iosHow to change the default inline string for custom structures and classes in Swift - swiftОшибка компиляции для python script в exe с использованием py2exe и pyttsx - pythonRails 4.1 cannot automatically load a class with names - ruby-on-railsHow can I order the results of several asynchronous jQuery queries? - javascriptBlur effect using Swift on iPhone - iosrhc setup undefined `[] 'method for nil: NilClass - openshiftAll Articles