Launch a legitimate popup when clicking on a user

I know that there are many threads on how to defeat popup blockers. In this case, I am not trying to do this. By default, browsers do not block all-pop-ups. Valid legal, for example, when users click on it. This is a good test: http://www.popuptest.com/goodpopups.html (works in IE, Firefox, Chrome, Opera)

As the aforementioned test site allows legitimate pop-ups, it directly associates the onclick event with the launch of a new window.

In my case, I cannot just launch a popup. I need to check if the user-entered alphanumeric password. As I did this, the input is checked through ajax, and if it is valid, it window.open()is called to launch the window. Alas, all the blocking pop-ups block this.

Is there any other way to do this? I do not want to start the window if the input is invalid. If the input is invalid, the error message is displayed on the first page, and not in a new popup. It is foolish to run a window to tell the user that it is invalid.

Any thoughts or suggestions, how can I check the input, and also allow the display of a legitimate popup?

Thank.

Edited to include my (simplified) code

HTML form:

<form id="form-passcode">
<input id="input-passcode" type="text" name="input-passcode" /><a class="submit" onclick="javascript:passcode_check(); return false;" href="javascript:">Go</a>
</form>

Javascript (using jQuery):

function passcode_check() {
    var refPasscode = $('#input-passcode');
    var data = $('#form-passcode').serialize();
    $.ajax({
      url: check_passcode.php',
      data: data,
      dataType: 'json',
      type: 'post',
      success: function (j) {
        if (j.status == 1) {
          newwindow = window.open('http://google.com','Google','menubar=no,height=500,width=300,resizable=no,toolbar=no,location=no,status=no');
          if (window.focus) {newwindow.focus()}
        }
        else {
          // show error to end-user
        }
      }
    });
}

}

, ajax, , , . <a href="http://google.com" onclick="newwin(this.href);return false" onfocus="this.blur()">Launch</a> $('#form-passcode').html();, , . , .

:)

+3
2

onclick?

: OnClick = "JavaScript: validateInput();"

validateInput(), , .

, , onclick jQuery. HTML.

+4

. , window.open, . AJAX async-, window.open . ( , - ), , window.open . async AJAX , .

, : , AJAX , URL- AJAX async.

+4

Source: https://habr.com/ru/post/1754741/


All Articles