Skip to content
Advertisement

How to execute a javascript function in a new window on a buttonclick in html

How to call a javascript function(Jitsi Meet API) on button click and open the result(meeting) in a new window, in this case the function has to open up a new Jitsi meeting I have a javascript function that calls the Jitsi Meet API and opens up or launches a new meeting on button click?

JavaScript

As of now, the meeting launches on the same page, It would be really helpful if the meeting opens up in a new window on button click.

In simple terms, button click on this page should open up a new window and execute the function in the new window. I want to know how this can be achieved and by using what method.Do guide with an example snippet

Thanks in advance

JavaScript

Below is the function and the file that has to be executed in a new window on button click- javascript.js

JavaScript

Advertisement

Answer

After researching a while, I finally figured it out

I made use of the window.open() in the current HTML script to open up new window and made use of document.ready(){} and loaded the script inside this function on loading the new window.

Voila!! It worked as per my requirement instead of calling the javascript on src i.e.,

<script src ="example.js"></script>

If you want to open a document/html in a new window and not tab on button click or link use the window.open() as shown below Syntax window.open(URL, name, specs, replace)

window.open("example.html","windowname","_blank","height=500,width=500");

This is what my function looks like now after modification

JavaScript

This is where the window.open() redirects to.

JavaScript

Conclusion

This tutorial demonstrates on how to open a new window(not tab) on button click and execute a javascript function and or script on opening the window.

Regards

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement