I understand that it's usually not a good idea to change a page's title, but I'm trying to do it anyway.
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?
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!
Thanks for the suggestions.
This is actually for a class, so I don't have the luxury of "not" actually doing this.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)