Creating HTML <a> Anchor </a> Tag With JAVASCRIPT
AakritiGoyal12458
Posted on August 1, 2022
This article will help you to create link over any text you have used in your webpage without using anchor tags of html .
Also whenever you will click on link it will ask you to confirm whether you want to continue or not ...
Step 1
We know Browser know our current workspace and JavaScript is the best way to communicate with browser . So with this command
document.location="delete_me.html"
JavaScript can ask for your current location from Browser .
Step 2
We have confirm dialog box in JS confirm()
which gives its o/p as Boolean values . These values can be used with if and else conditions .
Code:
<script>
function abc(){
var c= confirm("Do you want to Continue....?? ");
if(c)
{
document.location="delete_me.html";
}
else
{
alert("we stay here");
}
}
</script>
<body>
<div onclick=abc()>Click me </div>
</body>
💖 💪 🙅 🚩
AakritiGoyal12458
Posted on August 1, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.