Skip to content

Instantly share code, notes, and snippets.

@tieutantan
Created January 12, 2021 07:23
Show Gist options
  • Save tieutantan/ec2ff4bd0a00b3e779fb7841dbc14f92 to your computer and use it in GitHub Desktop.
Save tieutantan/ec2ff4bd0a00b3e779fb7841dbc14f92 to your computer and use it in GitHub Desktop.
JS alert without URL on the top of modal
function silentAlert(messages) {
let iframeElement = '<iframe style="display: none;" id="silent_alert"></iframe>';
document.getElementsByTagName('body')[0].innerHTML += iframeElement;
let ifrm = document.getElementById('silent_alert');
ifrm = ifrm.contentWindow || ifrm.contentDocument.document || ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write('<script>alert("' + messages + '");<\/script>');
ifrm.document.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment