Javascript is basically used for validation of forms by using alertbox.We can use javascript alertbox to Re-direct user to new web page with his/her permission. If you need that user must give his/her responce before re-direction then this technique is going to be usefull too for you. You can use it to recheck user's choice.
As we know javascript is basically a function that perform its task, we call this function on button with firing a click event named "onclick( )". We give function name into empty parantheses and apply it on button.
When user press button this function is called and javascript runs.
Here is the given code.........
As we know javascript is basically a function that perform its task, we call this function on button with firing a click event named "onclick( )". We give function name into empty parantheses and apply it on button.
When user press button this function is called and javascript runs.
Here is the given code.........
Code:
<html>
<head>
</head>
<body>
<p>Press button to see alert box</p>
<input type="button" onclick="myfunction()" value="Google">
<script type="text/javascript">
function myfunction()
{
var r;
r=confirm("Do you really want to go to this address ?")
if (r==true)
{
window.location = "http://www.google.com/";
}
else
{
alert("Thanx for not leaving us")
}
}
</script>
</body>
</html>
</head>
<body>
<p>Press button to see alert box</p>
<input type="button" onclick="myfunction()" value="Google">
<script type="text/javascript">
function myfunction()
{
var r;
r=confirm("Do you really want to go to this address ?")
if (r==true)
{
window.location = "http://www.google.com/";
}
else
{
alert("Thanx for not leaving us")
}
}
</script>
</body>
</html>
Please give your feedback, it will help us to enhance the quality of our matter.
Comments
Post a Comment
your Comment is sent for moderation, Thankyou