Rule Definition
This API is legacy synchronous modal dialog; removed from modern browsers
Remediation
Use the
Violation Code Sample
var result = window.showModalDialog('/confirm.html', {}, 'dialogWidth:300px;');
Fixed Code Sample
<dialog id="dlg">
<form method="dialog">
<p>Proceed?</p>
<button value="yes">Yes</button>
<button value="no">No</button>
</form>
</dialog>
<script>
async function ask() {
const dlg = document.getElementById('dlg');
dlg.showModal();
const choice = await new Promise(r => dlg.addEventListener('close', () => r(dlg.returnValue), {once:true}));
return choice;
}
</script>
Reference
https://learn.microsoft.com/en-us/previous-versions/ms536759(v=vs.85)
Related Technologies
Technical Criterion
CWE-710 - Improper Adherence to Coding Standards [Pillar]
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.