-
Javascript Button Links
I came across a javascript that can act as a 'phone' about 7 or 8 years ago. You sort of assign numbers to links .. i.e 017 or 999. Then on the webpage, there will be 10 buttons 0-9 and you can press a combination of numbers (i.e. press 9 three times) and it will take you to the website assigned to that combination.
Any idea where I can find such a script or similar? Thank you ^_^
-
Does this help you?
HTML Code:
<html>
<head>
<title>KeyPad Combination</title>
</head>
<body onLoad="generateKeypad(false)">
<script type="text/javascript">
var combination = "";
var disabled = "";
var innerR = "";
function includeNum(self){
combination += self.value;
if(combination.length == 3){
disabled="disabled";
generateKeypad(true);
switch(combination)
{
case "123":
window.location="http://google.com";
break;
case "890":
window.location="http://dynamicdrive.com";
break;
default:
window.location="http://yahoo.com";
}
}
}
function generateKeypad(){
innerR = "";
for(i=1;i<=3;i++){
innerR += '<button onClick="includeNum(this)" value="'+i+'" '+disabled+'>'+i+'</button>';
}
innerR += '<br />';
for(i=4;i<=6;i++){
innerR += '<button onClick="includeNum(this)" value="'+i+'" '+disabled+'>'+i+'</button>';
}
innerR += '<br />';
for(i=7;i<=9;i++){
innerR += '<button onClick="includeNum(this)" value="'+i+'" '+disabled+'>'+i+'</button>';
}
innerR += '<br /><button onClick="includeNum(this)" value="0" '+disabled+'>0</button>';
document.getElementById('keypad').innerHTML=innerR;
}
</script>
<div id="keypad">null</div>
</body>
</html>
I think that there are 3486784401 possible combinations. To add a new combination, before:
Code:
default:
window.location="http://yahoo.com";
Add:
Code:
case "digit":
window.location="website.com";
break;
Replace the red with the three digit number, and the blue with the site. To change the ones that I already put in, I think you can figure out by what I gave you above. :D If you can't. Just post. ;)
-
<333!!!!
thank you so much!!! you are such a star <33
-
Anytime, just took around 5 - 10 minutes. :)
-
Fantastic piece of coding, thanks for sharing. I'm a bit of a novice at this :confused: and am trying to use your code to do something slightly different.....what i'm trying to do is to create on screen ‘hotspots’ which will be invisible, and the location only known to the administrators. Once the correct sequence has been pressed the code will call up a specified url. My first thought was to make the keypad buttons bigger and somehow invisible….but it’s beyond my basic knowledge.
Can anybody help please