How can I press the alert ok button programmatically?

后端 未结 8 1131
有刺的猬
有刺的猬 2020-12-21 11:15

How can I press the OK button in a JS alert programmatically?

What I want to do: every time after the alert is created, the OK button is pressed.

This is for

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 11:41

    If you can simulate a keypress of the space bar or enter key, then that will dismiss the alert. However you'd better be doing this from outside whatever makes the alert show up in the first place, since they tend to be blocking.

    If this is JavaScript, you may be better off using console.log().

提交回复
热议问题