Wednesday, June 25, 2014

Opening new window/tab without using `` or `window.location.href`

Answer from

What it does:
  1. Create a form
  2. Give it attributes
  3. Append it to the DOM so it can be submitted
  4. Submit it
  5. Remove the form from the DOM
Now you have a new tab/window loading "" (or any URL you want, just replace it). Unfortunately when you try to open more than one window at once this way, you get an Popup blocked messagebar when trying to open the second one (the first one is still opened).
Source Code:

var form = $("<form></form>");
    id     : "newform",
    action : "",
    method : "GET",
    target : "_blank"        // Open in new window/tab


No comments:

Post a Comment