First of all, your code sample does not show any attempt to open a pop-up window, so it's hard to say if you have some bug.
Anyway, pop-up windows are pretty bad and should be avoided in most cases. They irritate many users, are intrusive (the user knows better what page to open in what window or tab, or just replace a current window content) and are often blocked in the browsers, using the browsers' options/plug-ins.
One good substitute for this questionable technique is simulation of modal behavior on the same page, as with jQuery dialog:
https://jqueryui.com/dialog[
^].
You can also find many 3rd-party plug-ins, collectively known as "modal popup", featuring different effects, such as transitions, and, notably, dimming of the rest of the window.
—SA