title: Put Login in Popup window
body: <p>I'm creating a login where you click on a button and it shows the login via <code> $(&quot;#loginbox&quot;).show();</code>, I want to show the contents in loginbox/<code>&lt;div class=&quot;loginContainer&quot;&gt;</code> in a popup window. I've been trying to use <code>window.open()</code> but I don't think it'll work for what I want.</p>
  <p>my code:</p>
  <pre><code>    const $document = $(document);
          const $login = $(&quot;#login&quot;);
          const $loginBox = $(&quot;#loginbox&quot;);
  
          const $formElement = $(`
            &lt;div class=&quot;loginContainer&quot;&gt;
              &lt;label for=&quot;userNameBox&quot;&gt;&lt;b&gt;Username: &lt;/b&gt;&lt;/label&gt;
              &lt;input type=&quot;text&quot; class=&quot;userName&quot;id=&quot;userNameBox&quot; placeholder=&quot;Enter Username&quot;required=&quot;required&quot;&gt;
              &lt;input type=&quot;button&quot; class=&quot;loginButton&quot; id=&quot;loginButton&quot; value=&quot;Login&quot;/&gt;
            &lt;/div&gt;
          `);
  $document.on(&quot;click&quot;, &quot;#loginButton&quot;, function() {
            const $userNameBox = $(&quot;#userNameBox&quot;);
  
            if ($userNameBox.val() !== &quot;&quot;) {
              location.href = &quot;mylink.com&quot;;
            } else {
              alert(&quot;Please Enter a Username.&quot;);
              location.reload();
            }
          });
  
            $('.login').click(function(e) {
  
            if ($loginBox.children().length === 0) {
              $loginBox.append($formElement);
  
            }
  
            $(&quot;#loginbox&quot;).show();
  
            event.preventDefault();
            return false;
          }); 
  </code></pre>