Creating HTML Anchor Tag With JAVASCRIPT

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 …

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>
Enter fullscreen modeExit fullscreen mode

Thank You



Source link

Comments 0

Leave a Reply

Your email address will not be published. Required fields are marked *