Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Personalised welcome message

    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
    Head
    <SCRIPT language="JavaScript">
    <!--hide
    var yourname= prompt('Please enter your name', ' ');

    if ( (yourname==' ') || (yourname==null) )
    {
    yourname="there";
    }

    //-->
    </SCRIPT>

    Body

    <SCRIPT language="JavaScript">
    <!--hide
    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.

    Thanks

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You will have to setup a cookie to remember the users name. http://www.quirksmode.org/js/cookies.html
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I probably will get rid of it now, this cookie business is confusing the hell out of me. :S


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •