Results 1 to 3 of 3

Thread: Page Title

  1. #1
    Join Date
    Feb 2012

    Page Title

    I understand that it's usually not a good idea to change a page's title, but I'm trying to do it anyway.

    I'm just learning JavaScript, and from what I can tell, I can change the page title from pulling info from a previous prompt.

    The below simply has the user enter his/her name as stated, and stores it as userName.

    var userName=prompt("Please enter your name to customize your shopping experience.", "default text");


    I'm thinking that I can change the title with this userName with an onLoad, like below:

    <BODY onLoad="mywindow.title=userName + "'s Page"/>

    Is this the right syntax for this statement, or do I need to do this some other way to accomplish what I'm trying to do?

  2. #2
    Join Date
    Mar 2011
    There's nothing terribly wrong about changing a page's title if you like, but before you go any further, I think you should carefully consider if this is a good idea. Even if users have a simple way of not answering the prompt, it's likely to cause many users to simply leave your site. New users enjoy their anonymity and many will be reluctant to provide any personal information on their first visit - even just their name. What you're doing is very different than a site that recognizes and greets a returning customer. If you're developing an online store, I would suggest you drop this idea.

    But if you decide to continue in developing your script, you'll want to include some way of storing the user's response so that he isn't asked for his name every time he reloads the page in question or visits any other page that includes the same script. A cookie would be the most common method for something like you're doing, and it's probably the most convenient. Good luck!
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Feb 2012

    Page Title

    Thanks for the suggestions.

    This is actually for a class, so I don't have the luxury of "not" actually doing this.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles