js: How to navigate to a new url and get a callback when the page is loaded?


Jarek

I'm trying to implement a JS function that navigates to a 3rd party URL and calls the function after this page is loaded;

document.location = "http://ww.example.com";
window.onload = function () { alert('example.com page loaded!") }

Can it be done?

Quentin

you can not

Before creating a new page, the execution environment of the first page will be destroyed. They cannot interact.

The closest you can possibly come is passing (via URL/Cookie/local storage) some data that another page is looking for in a script that is always running on it.

Related


How to get animation automatically when page is loaded

Kushagra Singh Rajput I want to make image effect automatically on page load. now i am using this code js $(window).ready(function(){ $(pin).click(function(){ $("#pin01").show().animate({left: '650px'}); }) }); Japanese html <p id="pin">Click me</p> <img sr

How to get animation automatically when page is loaded

Kushagra Singh Rajput I want to make image effect automatically on page load. now i am using this code js $(window).ready(function(){ $(pin).click(function(){ $("#pin01").show().animate({left: '650px'}); }) }); Japanese html <p id="pin">Click me</p> <img sr

Will JS variables be destroyed when a new html page is loaded?

Ollie Just a simple question. When you have a js file with normal functions, variables and other stuff, the page will be loaded and then used when code is needed. But my question is, for example, what happens to any/all variables you create when you navigate t

Will JS variables be destroyed when a new html page is loaded?

Ollie Just a simple question. When you have a js file with normal functions, variables and other stuff, the page will be loaded and then used when code is needed. But my question is, for example, what happens to any/all variables you create when you navigate t

Geckofx get loaded page url

Manvik I am using geckofx-22 in a WPF application. I want to check the current URL of the page loaded in the geckofx control. Could not find any properties for the same. Manvik Use the following code for WPF and put it in Geckofx-WPF GeckoWebBrowser.cs ///

Navigate to a new page when the search bar is clicked

Chedan I am using react native element search bar. By default, when the user clicks the search bar, a keyboard with a "return" key is displayed in the lower right corner. How can I change it to show the keyboard with the bottom right "Search" key? Also, when I