Javascript Confirmation and variations
Regular confirmation java
1 2 3 4 5 6 7 8 9 10 | <script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Welcome to Tom's Blog if you want to come in select \n\"OK\"\nor\n\"Cancel\" if you want to leave")
if (!answer){
alert("Bye Bye Douchey!");
history.go(-1); }
else{ alert("Thanks for sticking around!") } }
document.writeln(confirmation()) //This will make the popup come up when page is loaded (So disable if you want to call it like I have) //-->
</script> |
Code for Confirm button:
1 | <form> <input type="button" value="Confirm button" onclick="return confirmation();"> </form> |
Check if name is correct, if not bye bye!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <script type="text/javascript">
<!--
function testname(){
var name = prompt("Please enter your first name: (Remember it is case sensitive)","Stephen");
if (name == "Fred" || name == "Suzi" || name == "Crafty" || name == "Stephanie" || name == "Cindy"){
alert("Welcome to Tom's Blog " +name);
if (name == "Thomas"){
window.location.href="http://www.thomasnorberg.com/wp-login.php"; }
}
else { alert("Bye Bye Douchey!")
window.location.href="http://www.google.com";
}
}
document.writeln(testname()) //This will make the popup come up when page is loaded (So disable if if you want to call it like I have)
//-->
</script> |
Code for Name prompt button:
1 2 3 | <form action=""> <input type="button" value="Name Prompt" onclick="return testname();" /> </form> |
GD Star Rating
loading...
loading...
GD Star Rating
loading...
loading...
| Print article | This entry was posted by Tom on May 1, 2009 at 12:36 am, and is filed under Computer Programming. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |


