1

I need to modify a form submission script to open a PDF in a new tab upon success.

As it stands, when it succeeds, it already shows a notice of thanks and clears the form. I just need the jQuery to open the PDF in a new tab. I've only been able to open a new window with window.open(), which is promptly blocked as a pop-up.

user1729506
  • 975
  • 4
  • 15
  • 28
  • by default `window.open()` should open a new tab if no window name is specified. – Yuriy Galanter Mar 06 '14 at 22:40
  • possible duplicate of [How to add target="\_blank" to JavaScript window.location?](http://stackoverflow.com/questions/18476373/how-to-add-target-blank-to-javascript-window-location) – celerno Mar 06 '14 at 22:41
  • @YuriyGalanter Would the fact that it's not being used with a click event make a difference? – user1729506 Mar 06 '14 at 22:42
  • Well, you *want* a popup? – Bergi Mar 06 '14 at 22:42
  • 1
    You should find an answer [here](http://stackoverflow.com/questions/6628949/window-open-popup-getting-blocked-during-click-event). – Linek Mar 06 '14 at 22:42
  • New windows only open in new tabs **if I've allowed it** in my browser settings. (You cannot over-ride the browser's handling of this.) – Sparky Mar 06 '14 at 22:52

1 Answers1

3

You can't directly control this; it's down to the browser and its settings.

jQuery is JavaScript, so there's nothing jQuery can possibly provide that isn't available to you in native JS, and all JS provides is window.open(), which, as you've found out, is normally blocked unless it's the result of a (real, not simulated) click event.

Mitya
  • 33,629
  • 9
  • 60
  • 107