Call function javascript from other window browser

To call a JavaScript function from another window in Yii2, you can use the window.opener property to get a reference to the parent window and then call the function using that reference. Assuming that you have a function named myFunction in the parent window, you can call it from the child window like this:

In the parent window:

function myFunction() {
   // Your code here
}

In the child window:

window.opener.myFunction();

You can also pass arguments to the function by including them in the parentheses, like this:

window.opener.myFunction(arg1, arg2, ...);

Note that this method will only work if the child window was opened using window.open() from the parent window. If the child window was opened in a different way, you may need to use a different method to communicate between the windows, such as using window.postMessage().

Komentar

Postingan populer dari blog ini

WhatsApp Web login QR code in an HTML page using whatsapp-web.js

Node.js Telegram Bot API send an image with text

Add these security headers to your website