Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Say you want people who know you to have access to your phone number. Is there some HTML (or other) lines I could put in my HTML to do this? Like, if I said "What is the name of the town I grew up in?" And if they answer it right, it opens up the new page to give them my phone number. Or the number is displayed onscreen.

you could just not give an area code...or heres some java script i found on a web page, although you can just get the source, and figure it out...
[script language="JavaScript"]
[!--
function Try(passwd) {
if (passwd =="AnyTown") {
alert("My phoneNumber is...555-5555");
}
else {
alert("The password is incorrect. you are not a privleged person.");
}
}
//--]
[/script]
and then somewhere on the page...:
[!-- content --]
Enter the town i was born in:[form name="pass"][input type="password" name="txtpasswd" size="20"] [input type="reset" value="click here to continue" onclick="Try(pass.txtpasswd.value)"][/form]
[!-- end content --]yea, its really simple...got it off a web page...plargerism..oh well. change the [ to the less then, and the ] to the greater than, and it should work i think. i dunno to much html though, or javascript. hope this helped some
eaw8806

This can be done in JavaScript. A very simple code, since it's obviously for a project of some sort then I'll just hand it to you. However, in this case anyone can look at your source code and find the answer.
So what I would recommend, is writing the following code in a seperate text file and renaming the extension to be .js and linking it into your HTML. That way it'll be masked from anyone who goes to your site.
Here's the code:
var answer;
window.prompt("Where Do I Live?",answer);
if (answer = "Hawaii")
document.writeln("My Number Is: 999-9999");
else
document.writeln("Idiot!");
As you can see, there is an equality check to see if the location matches up. This is why I recommend you linking it from a JavaScript file. There are other ways of approaching this, but I just thought I could provide some help.
- Rolos

Javascript can perform this function (perhaps use the "if" statement). However the answers are all still contained in the HTML source, or a another viewable source file.
You probably do not want to put personal information into your webpage. If it is part of the HTML, it will be viewable by anyone - with or without the correct answer.
To hide the information from the user (perhaps until they have provided certain information), use something that is parsed by the server. PHP, ASP, CFM, and other scripting languages allow you to hide to information until certain conditions are met.
The most common example of this is inputting a username and password and recieving a result based upon that input.
If you choose to use javascript (I would advise against it if the information has any importance), keep your information in a seperate javascript file. This may keep some idiots from finding it.
There are thousands of tutorials and examples of this usage of scripting. Google is your best friend with these sorts of things.

Rolos, you said --
So what I would recommend, is writing the following code in a seperate text file and renaming the extension to be .js and linking it into your HTML. That way it'll be masked from anyone who goes to your site.
Here's the code:
var answer;
window.prompt("Where Do I Live?",answer);
if (answer = "Hawaii")
document.writeln("My Number Is: 999-9999");
else
document.writeln("Idiot!");
As you can see, there is an equality check to see if the location matches up. This is why I recommend you linking it from a JavaScript file. There are other ways of approaching this, but I just thought I could provide some help.
- Rolos
=====
I dont' know much. Uh...
I create a text file with what you said.
I rename it .js
THen what? I make a regular HREF link in my HTML page? Is it going to create a new page and write the answer?Thanks to all for help. Cool.

Just a word of warning, the contents of a JS file can easily be retrieved if the person knows what they are doing.
I agree with anonproxy. This can easily be done with a number of server-side scripts. What web server are you running, or who is hosting your site? They may have support for various scripting languages.
If you do want to use a JS file then do something like this:
======================
=== Your HTML file ===
======================
<HTML>
<HEAD>
<SCRIPT SRC="whatever.js" LANGUAGE="JavaScript"></SCRIPT>
</HEAD>
<BODY>
.
.
.
<FORM NAME="form">
<INPUT TYPE="password" NAME="pass"><P>
<INPUT TYPE="button" onClick="javascript:getPhone();"
VALUE="Get number">
</FORM>
.
.
.
</BODY>
</HTML>
======================
===== whatever.js ====
======================
if (document.form.pass.value == "your_password")
alert("My phone number is: 555-5555");
else
alert("Wrong, go away.");
That should do it for you. Give it a try and let us know if it worked. There are other ways to do this, such as an input box like Rolos used, but they all work about the same.

Hey Bill,
I got a method that you could use. I can write it for you if you gave me whatever state you were planning on using. Either that or I can post up a tutorial that I am creating to show you how to do it on your own.
Pay no heed to my previous entry, there is a good chunk of it that does not work. I'm here to help, not to deceive or betray. But I leave that totally up to you. I would not blame you if you do not trust me with it. I am willing to help, but I leave the choice up to you.
- Rolos

Storing the password in a different .js file is not a solution because all those files will be visible in the "temporary internet files".
What you could do is to create two html pages the first contains a textfield and a button.
The second contains your personal data you want to protect and you put the password as the name of the file. (ex: passwd.html)When you click on the button of the first page, you open a new page whose URL is build with javascript using the password given as filename.
It's rather basic but it works.
People giving a bad password will have a 404 error.- cerj

Dr. Nick, that doesn't work. Are you sure the onClick is correct? getPhone -- that doesn't look right. I tried every conceivable fix.
Rolos, it would be cool to see what you could do. Our server is Linux, I think. Apache. I've done Perl scripts on there. Just did phpBB, which works flawlessly, so php is cool. My brother is expert at javascript (out of town) but if it's not secure, wouldn't want to use it.
cerj, sounds good to me what you said about having two html pages. Whatever works, guys.

var answer;answer = window.prompt("Where Do I Live?", "");
if (answer.charCodeAt(0) == 72 &&
answer.charCodeAt(1) == 97 &&
answer.charCodeAt(2) == 119 &&
answer.charCodeAt(3) == 97 &&
answer.charCodeAt(4) == 105 &&
answer.charCodeAt(5) == 105)
document.writeln("My Phone Number Is: 999- 9999");else
document.writeln("If You Don't Know Where I Live, You Can't Get My Password");Cut and paste this code into an HTML file. Do not forget your >script< tags along with them. The password is 'Hawaii'. As you can see all I did was convert each character in the string to their numerical values using charCodeAt(). I could have converted the whole string to a numerical value but I think that it would be a bit more painstaking to crack this way.
This method also ensures that the page viewer does not see the real password, rather they see the extremely pathetic 'encrypted' version of it. Let me know if you want to use this method and I hope this helps to a certain extent.
- Rolos

Hey Rolos, it worked. I'm not much of a programmer and you said include Script tags. Took me awhile to figure it out but finally got it done that it works fine.
Where could I view charCodeAt() values?
I guess my question next is about using JavaScript. If someone's browser doesn't use it, they can't use it, right? Just wondering of the best way. Plus, 99% of the general public is of no concern. But your method, would it solve the problem, since someone knowing how to view code would know aoubt charCodeAt() values? Or are these unusual values?
Lastly, I would give them more than once question. Like, what's my dog's name? What is the mascot of the college I graduated from? etc. It could be fun. Maybe even have humorous error statements.
Thanks!

Say, maybe this is a little better, Rolos?
1. I put that last JavaScript code you posted in a text file and named it phone.js
2. FTPd to my server
3. Wrote a simple HTML page and put this in there to call that script (someone told me how)...[script src="phone.js" language="javascript" type="text/javascript"][/script]
Of course, the [ means etc.
So, it works the same but nobody can view source code and see how it works. How could someone view my phone.js file? That would be some serious cracking, wouldn't it?

Well actually there wouldnt be much cracking involved. They can still get the file from their browser's cache (I believe) and open and read the script. Or by downloading the file through your server unless you restrict access to it. All they'd have to do is add phone.js to the end of your main page's URL and they have instant downloading access.
With the method I gave you, you could write and add a series of functions that could totally throw off the numerical value of the password content's characters and store that into another variable then do more comparisons. This will further make it a pain in the ass for people to try and crack.
The value of charCodeAt() returns the value of one letter in the string specified by the programmer. So for example if I used:
var password = "Oregon";
I would do the following to get the numerical value of the letter 'O'.
document.writeln(password.charCodeAt(0));
This will print the value of 'O' on an HTML page. You would increase the number inside of charCodeAt() by 1 for the next letter in the string. So for example if I wanted the numerical value for 'r' in Oregon I would do the following:
document.writeln(password.charCodeAt(1));
And this will give me the numerical value of the letter 'r'.
There are sooooo many different ways to go about this, since I don't have any or a lot of experience with using servers and php forms and what have you, I use Javascript to work around that. So I mean what I gave you is just the very beginning of what you could do.
There are also encryption algorithms available that you could use in your script. But I do not not know how big you are planning on taking this. From what it seems, this seems like a pretty big project for you.
I hope this helps, if you need more explanation please leave a comment.
- Rolos

P.S. Bill - You would create even more blocks of the stuff that I have given you, except you create more variables to hold these answers for you to do your comparisons.
If you want to write anything to an HTML page using Javascript use the following:
document.writeln("Message");
I will soon be putting up a tutorial page on a great deal of programming languages put together by myself and many other greater programming demons from this forum. So if you need any help in the future, be sure to stop by and I'll provide that URL for you. Mind you it won't be for another month or so before the very first prototype is put up.
- Rolos

I was asking where I could view the codes cuz it seems to me there must be a table somewhere. Apprently 105="i"
Otherwise, I'm really lost. I googled and read some on charCodeAt but it didn't explain to me. I mean, we have "Hawaii" now but if I want to change that, I don't know how.
Is it easy to restrict access to my phone.js file? Permission setting or something else?

Rolos simply converted the string value "Hawaii" into numerical code (according the the Unicode Latin-1 standard). Ironically enough, discerning the correct character match is harder than finding the phone number.
The table you are looking for can be found here:
http://www.bbsinc.com/symbol.html
"Is it easy to restrict access to my phone.js file? Permission setting or something else?"A default web server installation means everything is accessable in your root index (such as www.computing.net/[THIS IS ROOT]).
So if I wanted to see your js file, I would write its URL into my browser. cerj had a good workaround, which essentially creates a the link to the answer based upon your input. If your input is wrong, the link created is wrong.
However, you cannot have security with client-side javascript.
Methods of implementing security include making use of .htaccess features in apache, using a database (which can handle users and permissions) to protect your data, or using a server-side scripting language (where you can hide your code and only display output).
It is a popular scripting design to combine a database and a server-side scripting language together (like MySQL and PHP).
http://www.tmisnet.com/~engholm/books/htmljavascript/CH14.html#ch14xxx11

I meant to post on this topic some time ago, but forgot. Cerj stole my thunder in the meantime though...I've used that method a few times, and although I'm sure there is a way around it, it's not known to the common web surfer like myself. I'm no hacker, and getting at those js files is a piece of cake even for me. Decoding the password wouldn't be too tough either, but if I wasn't willing to spend 15 extra minutes to see what dark secrets you're hiding on the page, I'd move on.
I'm endorsing the method, of course, assuming a server-side method is out of the question for whatever reason.
I haven't gotten my hands on the intellitxt js for this forum though...Something about how the asp outputs it. Has anybody else gotten it? I'm very curious to see how they fixed the sticky scrolling problem.
-SN

Here is a link to a script that passes a password to be part of a URL --
http://javascript.about.com/library/scripts/blpassword.htm

isnt the chrCodeAt thing just ASCII? and even i know that...
A = 65, or in binary 01000001
B= 66, 01000010
ect...
and
a = 97, 01100001
b = 98, 01100010
ect...
so all uppercase start with 010, then the letter code, and lower case letters start with 011.
im not sure if its the same, but if Hawaii is chr(72), chr(97), chr(119), chr(97), chr(105) and chr(105) then i think at least for the letters it is ASCII.also, coulndt you for another method, just have the pass word's chr values added to a number, and then that number given out as the phone number? for example, if your phone number was 123-4567, and the password was gfedcba, then you could subtract 96 from each of the chr's first off, so the strings chrs are now 7,6,5,4,3,2,1...then you subtract those from the your original phone number, so the new phone number is -6, -4, -2, 0, 2, 4, 6. then store those.
when the password is entered, you add each chr (-96) to the number, and then print that number...so if they enteredin "aaaaaaa" in this example, then the phone number would come out to be 531-1357, if you make the numbers positive, just to simplify the output. this is just another way to store it without actually storing the actuall number, although the above method by DuckWill would also work.
hope this helps...
eaw8806

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |