Home>

Task to intercept the alerts, confines, and so on from the site and output in the custom block. There is a solution for Alert () But for the rest of the confirm () prompt () fails.

JQuery (Document) .ready (FUNCTION ($) {
    Window.Realalert= Window.alert.
    Window.alert= Function (S) {
        Customalert (s)
    }
  Alert ("Test");
    FUNCTION CUSTOMALERT (S) {
        if ($ (# Customalert ') [0]) {
            If ($ (# Customalert '). Hasclass (' ON ')) {
                $ ('# Customalert'). Find ('. AlertText'). HTML (S);
            } ELSE {
                $ ('# Customalert'). AddClass ('ON'). Find ('. AlertText'). HTML (S);
            }
        } ELSE {
            $ ('BODY'). Append ('<
DIV ID= "Customalert" class= "on" >
≪
DIV ID= "Customalert_Cnt" >
≪
DIV ID= "IC_W_PP" >
≪
SVG width= "60" height= "60" viewbox= "0 60 60" Fill= "none" xmlns= "http://www.w3.org/2000/svg" >
 ≪
Rect x= "1" y= "1" width= "58" height= "58" rx= "29" fill= "# FF7875" />
 ≪
path d= "M30 48C39.9249 48 48 48 39.9249 39.9249 12 20.0751 30C48 12C20.0751 30 12 12 20.0751 12 20.0751 48 39.9249 30C12 30 48ZM30 45.2308C21.5733 45.2308 14.7692 38.4267 14.7692 30C14.7692 21.5733 21.5733 14.7692 30 14.7692C38.4267 14.7692 45.2308 21.5733 45.2308 30C45.2308 38.4267 38.4267 45.2308 30 45.2308ZM31.3846 38.3077L31.3846 35.5385H28.6154L28.6154 38.3077H31.3846ZM31.3846 32.7692L31.3846 21.6923H28.6154L28.6154 32.7692H31.3846Z "fill="white " /≫
 ≪
Rect x= "1" y= "1" width= "58" height= "58" rx= "29" Stroke= "White" Stroke-Width= "2" />
 ≪
/SVG >
≪
/div >
≪
Span class= "AlertText" >
'+ s +' <
/span >
≪
/div >
≪
/div >
');
        }
        $ ('# Customalert'). Fadein (250);
    }
    $ (Document) .on ('Click', '#Customalert', Function () {
        $ (this) .RemoveClass ('ON'). Fadeout ();
    });
}); 
#Customalert {
    Display: None;
    Overflow: Hidden;
    Padding: 40px;
    Position: Fixed;
    Top: 0;
    left: 0;
    Right: 0;
    Bottom: 0;
    z-index: 9999;
    Font-Size: 20px;
    Background-Color: RGBA (38, 38, 38, 0.75);
    -WebKit-Backdrop-Filter: Blur (3px);
    Backdrop-Filter: Blur (3px);
}
  #Customalert_Cnt {
    MAX-WIDTH: 500px;
    Position: Absolute;
    Padding: 40px;
    Background-Color: #FFF;
    Top: 40%;
    Left: 50%;
    TRANSFORM: TRANSLATEX (-50%);
    Border-Radius: 2px;
  }
#IC_W_PP {
    Width: 60px;
    Height: 60px;
    Position: Absolute;
    Top: -30px;
    left: -30px;
}
  .alerttext {
    Color: # 262626;
    Font-Size: 18px;
    Line-Height: 26px;
    font-weight: 400;
} 
<
script src= "https://cdnjs.cloudflare.com/ajax/libs/JQuery/3.3.1/jquery.min.js" >
≪
/script >

What exactly does not work with CONFIRM and PROMPT?

Grundy♦2021-06-28 11:27:15

It is impossible to customize similarly to the alert. I do not know how to do it.

Владислав Горбачев2021-06-28 11:46:18

Replace Alert on Confirm or Prompt

Grundy♦2021-06-28 11:49:54

Helped, only the buttons disappeared "OK" and "Cancel"

Владислав Горбачев2021-06-28 12:07:07

In the sense of gone?

Grundy♦2021-06-28 12:22:25