search

Home  >  Q&A  >  body text

javascript - Can I use js to cancel the alert window?

Recently I wanted to operate the company's business system (web page) directly in emacs
So I used elisp to write a websocket server, and then I wrote a client in the business webpage using Grease Monkey Script. After connecting, I call a function in emacs to send instructions to the client. After receiving the instructions, the client executes the corresponding instructions. DOM operation, but after the operation is completed, the web page will pop up the alert window, and you must click OK.
Can I use js to control the alert? Let alert not be displayed or press Enter automatically after displaying?
thank you all

为情所困为情所困2711 days ago811

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-06-12 09:22:43

    The

    alert() function actually calls the window.alert() function, so it is very simple to stop it from being displayed. Just add a line directly to your script

    window.alert=function(){}

    That’s it.
    Accident or not? Violent or not?

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-06-12 09:22:43

    If the pop-up window pops up by the alert() method of native Javascript, it cannot be closed through JS code. It is recommended to use a custom pop-up window to implement the function, such as using x0popup to replace the pop-up window function. We hope to adopt it!

    reply
    0
  • Cancelreply