Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

obtain reference to _blank target window on form submit

I have a form that is opening a new window on submit:

<form id="form-id" target="_blank">

I want to access the newly created window via javascript, without manually generating a unique name for target, and without resorting to an alternative method for opening the window.

It seems like there has to be an easy way of doing this but I wasn't able to find one that will work in my specific situation.

like image 537
jtrick Avatar asked Nov 26 '12 17:11

jtrick


1 Answers

Instead of _blank then you can use name your new window.

 <form id="form-id" target="newName">

Then you can use it in JS by doing:

var newWindow = window.open(null, 'newName');
like image 84
Naftali Avatar answered Oct 17 '22 16:10

Naftali