Call javascript on window that triggered another window to open

I have index1.html and index2.html

From index1.html I opened index2.html using window.open(‘https://localhost/index2.html’, ‘windowName’, ‘width=500, height=350, left=24, top=24, scrollbars, resizable’)

How to I call a script on index1.html from the newly opened window?