View Full Version : Personalised welcome message

07-04-2006, 06:53 PM
I'm coding a HTML portfolio for my I.T class at school and I am very new to Javascript. On the home page of the portfolio I have a script that gets viewers to enter there name a get a personal greeting. I have inserted this tag on to my page

<SCRIPT language="JavaScript">
var yourname= prompt('Please enter your name', ' ');

if ( (yourname==' ') || (yourname==null) )



<SCRIPT language="JavaScript">
document.write("<CENTER><H1>Hello, " + yourname + " ! Welcome to

My E-Portfolio! <\/H1><\/CENTER>");

It works fine but I was wondering if its possible for it to just do it the first time a viewer opens the page. Its pretty annoying going back to the home page and getting the prompt to enter your name every time.


07-04-2006, 08:24 PM
You will have to setup a cookie to remember the users name. http://www.quirksmode.org/js/cookies.html

07-04-2006, 09:02 PM
Will this still work even though my portfolio will not be put on the internet? It will be sent away on CD-ROM to an examiner.

07-04-2006, 09:10 PM
Yeah cookies can be set locally or on a server. Personally though I think the prompt is a waste of time. As its the noob javascript thing to do. No offense of course. Unless the examiner will be mainly looking at your JS then I guess it will be okay.

07-04-2006, 10:23 PM
They will be looking at everything I do so I'm gona put in as much of everything as possible. I have very little JS on the whole thing so I can't really remove it. Thanks for the help btw.

07-04-2006, 10:34 PM
I probably will get rid of it now, this cookie business is confusing the hell out of me. :S