Is it possible to insert HTML code in a JavaScript confirm box?
I just tried & it does not seem to work (I try to add a HTML link), see my code below
<html>
<head>
<script type="text/javascript"> function show_alert() { confirm(<a href="www.url.com">Link text</a>); } </script>
</head>
<body>
<input type="button" onclick="show_alert()" value="Show alert box" />
</body>
</html>
I suspect I might have to use a library such as "jquery-ui's dialog" to get this working
The confirm() method displays a dialog box with a message, an OK button, and a Cancel button. The confirm() method returns true if the user clicked "OK", otherwise false .
A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
Javascript | Window confirm() Method The confirm() method is used to display a modal dialog with an optional message and two buttons, OK and Cancel. It returns true if the user clicks “OK”, and false otherwise. It prevents the user from accessing other parts of the page until the box is closed.
Alert box is used if we want the information comes through to the user. Confirm box is used if we want the user to verify or accept something. 2. You need to click “OK” to proceed when an alert box pops up.
You can only insert plaintext to alert(), confirm() and prompt() boxes.
No, it isn't possible with the alert function.
However, if you want confirm boxes with html code, you could add a <div> with an absolute position on the screen, which can contain any html you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With