display things by the name they enter

T

trpplayer

Dear,

I want to create an page where they have to enter ther name in an prompt.
by the name they entered i want to open different html page's

example:

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">

var name;

name = prompt('Give your name please:');
if (name != "myname")
{
1.html;
}
else
{
2.html;
}
</SCRIPT>


my question is: how can i load these file's automaticly?

greetz Dirk
 
M

Michael Winter

I want to create an page where they have to enter ther name in an prompt.
by the name they entered i want to open different html page's

Try:

<!--
The language attribute is not
required and it's use is discouraged
-->
<SCRIPT type="text/javascript">
function loadPage() {
switch( window.prompt('Please enter your name').toLowerCase()) {
case 'fred':
window.location = 'fred/index.html';
break;
case 'jill':
window.location = 'jill/index.html';
break;
case 'bob':
window.location = 'bob/index.html';
break;
case 'amy':
window.location = 'amy/index.html';
break;
default: // Loaded when no match for the entered name is
// found
window.location = 'no_such_name.html';
break;
}
}
</SCRIPT>

I assume that the names will be case-insensitive (hence the call to
toLowerCase()).

You could then call this function on a button press. For example,

<BUTTON type="button" onclick="loadPage()">Load user page</BUTTON>

You could also use an INPUT element instead of a prompt window.

Mike
 
K

kaeli

Dear,

I want to create an page where they have to enter ther name in an prompt.
by the name they entered i want to open different html page's

Not sure why...
example:

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">

Lower case, I believe, is standard.
var name;

name = prompt('Give your name please:');
if (name != "myname")
{
1.html;
Change to
top.location="1.html";
}
else
{
2.html;
Change to
top.location="2.html";


--
 
T

trpplayer

Thank you, this work's fine

By using this, only the persone for who is has been created can read it and
the rest get an blank page whith "NO ACCESS" or something like that
 
R

Robin Goodall

trpplayer said:
Thank you, this work's fine

By using this, only the persone for who is has been created can read it and
the rest get an blank page whith "NO ACCESS" or something like that

So I just disable javascript goto this page and look at the source (or
get the source via one of a multitude of ways that don't evaluate the
javascript). I see "myname". I enable javascript, reload the page, use
the 'secret' "myname" and get to 1.html. Or having seen the source I
just go directly to 1.html

You cannot secure your site with client-side scripting, it needs to be
done server-side. Well, I cannot see a way you could anyway but I bet
someone here will say otherwise.

Robin
 
K

kaeli

You cannot secure your site with client-side scripting, it needs to be
done server-side. Well, I cannot see a way you could anyway but I bet
someone here will say otherwise.

Nope, can't be done.
Any idiot can view a source.
Anyone with enough free time can figure out a way around client-side
"protection", no matter how obfuscated it is. This has been discussed to
death here.

Best you can do is Flash. That's pretty hard to crack. A person needs to
get the Flash, decompile it, etc.
But it CAN be done.

--
--
~kaeli~
Is it true that cannibals don't eat clowns because they
taste funny?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top