I have the following text that needs to be displayed from Javascript ALert.
I am wondering if we can display the hyperlink from the alert itself?
alert('User already exists in the system, please <a href='../Login.aspx'>login</a>');
Appreciate your responses
Thanks
I have the following text that needs to be displayed from Javascript ALert.
I am wondering if we can display the hyperlink from the alert itself?
alert('User already exists in the system, please <a href='../Login.aspx'>login</a>');
Appreciate your responses
Thanks
Share Improve this question asked Feb 23, 2010 at 18:33 RitaRita 1,2376 gold badges24 silver badges47 bronze badges 1- Does this answer your question? Link in Javascript alert – outis Commented Oct 17, 2022 at 20:52
3 Answers
Reset to default 5No. You will have to make your own dialog if you want to do so (just make a modal dialog which should be pretty easy to do).
The alert box itself is just a simple text box.
If you only have one hyperlink, why not tie it to the OK button?
var answer = confirm("Flash Update Required. To get the latest version of Flash click ok.")
if (answer) {window.location = "http://get.adobe./flashplayer/";}
else {}
As the previous poster states, no.
You can have a div that you display with the message though. You could try something like this?
<html>
<head>
<title>JavaScript test</title>
<script type="text/javascript" language="JavaScript">
function show(message) {
document.getElementById('messageboxframe').innerHTML = message;
document.getElementById('messageboxframe').style.display = 'block';
document.getElementById('messageboxoverlay').style.display = 'block';
}
function hide() {
document.getElementById('messageboxframe').style.display = 'none';
document.getElementById('messageboxoverlay').style.display = 'none';
}
</script>
<style type="text/css">
html, body, div
{
padding: 0;
margin: 0;
}
.messageboxoverlay
{
position: fixed;
width: 100%;
height: 100%;
opacity:0.75;
background-color: rgb(200,200,200);
}
.messageboxviewer
{
position: fixed;
cursor: pointer;
min-width: 400px;
min-height: 200px;
left: 40%;
top: 30%;
background-color: White;
padding: 10px;
}
</style>
</head>
<body>
<div class="messageboxoverlay" style="display:none" id="messageboxoverlay" >
</div>
<div class="messageboxviewer" style="display:none" id="messageboxframe" onclick="hide()">
<span id="messagebox" />
</div>
<div style="margin: 5px 5px;">
<a href="javascript:;" onclick="show('hello')">show messagebox</a>
</div>
</body>
</html>
In the messageboxviewer div, you can write "whatever you want". Or you could do as the example and display a message from a function.