'how can I change pop up background color when called with javascript

I'm trying to call a pop-up with JavaScript, but I need to change the background color when the pop-up shows, but every time I try it changes the whole page color. Is there a way I can fix this?

This is my code: pop up background color needs to stand out of the html and have a overlay with transparent color.

setTimeout(() => {
    (function (proxied) {
        window.alert = function () {
            iosAlert(arguments[0], arguments[1]);
        };
    })(window.alert);

    function iosAlert() {
        try {
            var $alert = document.querySelector('.alert');
            $alert.parentElement.removeChild($alert);
        } catch ($error) {}

        var $alert = document.createElement('span');
        if (arguments[1] == null) {
            arguments[1] =
                window.location.protocol + '//' + window.location.hostname;
        }
        $alert.innerHTML =
            '<div class="alert"><div class="inner"><div class="title">' +
            arguments[1] +
            '</div><div class="text">' +
            arguments[0] +
            '</div></div><div class="button">OK</div></div>';
        document.querySelector('body').appendChild($alert);
        setTimeout(function () {
            document
                .querySelector('.alert .button:last-child')
                .addEventListener('click', function () {
                    $alert.parentElement.removeChild($alert);
                });
        });
        return false;
    }

    iosAlert('Hello World');
}, 1000);
body {
    background: #333 url('https://pixabay.com/get/e837b20a2ff5093ecd1f4604e4484093ea6ae3d11eb2124293f7c179/fire-1235718.jpg') no-repeat center center;
    overflow: hidden;
}

.alert * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.alert *:focus {
    outline: 0
}

.alert {
    position: fixed;
    top: 50%;
    left: 50%;
    margin-left: -135px;
    margin-top: -50px;
    width: 270px;
    text-align: center;
    font-family: -apple-system, SF UI Text, Helvetica Neue, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    border-radius: 13px;
    overflow: hidden;
    z-index: 9999999999999999999999998;
    background-color: rgba(255, 255, 255, 0.8);
}

.alert .inner {
    padding: 15px;
}

.alert .title {
    font-weight: 500;
    font-size: 18px;
}

.alert .text {
    margin-top: 5px;
}

.alert .button {
    position: relative;
    height: 44px;
    line-height: 44px;
    font-size: 17px;
    color: #007aff;
    border-radius: 0 0 13px 13px;
    overflow: hidden;
    cursor: pointer;
}

.alert .button:after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 1px;
    width: 100%;
    display: block;
    background-color: #c4c4c4;
    z-index: 9999999999999999999999999;
}


Solution 1:[1]

That code works.
You should use a smaller number for the .alert background alpha part (so rbga(255,255,255,/*smaller number*/)). And the body's background color is #333.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user17517503