Build a new Web page named l4p2html with a link back to your

Build a new Web page named l4p2.html with a link back to your index page. The text of the link must be \"Do not click here.\" Test that clicking the link really takes you to your index page. Now use JavaScript to create an alert with the message \"Stop that!\" that is displayed when the link is clicked. Clicking the link should not any longer take you anywhere. (However, the browser\'s \"Back\" button will continue to work so there\'s someway out of there!) Make a link from your index page to l4p2html.

Do not change the href= portion of the link. Do it all with JavaScript. The whole point of this exercise is for you to learn how use JavaScript to prevent the default action of an HTML element like a link, OK?

Solution

<html>
<head>
<title>Target</title>
<meta charset=\"UTF-8\">
<script>
function donothing(tar) //when the function triggers reference of the page will be blank.
{
alert(\"stop that.\");
tar.href=\"\";
}
</script>
</head>
<body>
<a href=\"index.html\" onclick=\"donothing(this)\">Do not click here.</a>
</body>
</html>

Build a new Web page named l4p2.html with a link back to your index page. The text of the link must be \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site