简体   繁体   中英

what is the best way to display website visitors a one time welcome message?

I've got a website, and I want to add a welcoming message which hovers on a certain part of the page which only loads for the visitor for the first time they login, and won't again(presumably cookies used). And says something like "adjust your settings here.." I don't want it to be an external popup but something that loads on the page in a certain area, defined by me (PX-pixle reference)

What would be the best coding language to do it in, oes anyone have any examples of this, or any site based generators to make it on? thanks

Create one more field in database with lastlogin . When user is created then make lastlogin field with special .

When user signs the next time from Login Page , update the field the lastlogin value to regular

//query to get value of lastlogin

//add css to elements you want to hover

<element class="<?php if($last-login == 'sepcial') { echo 'sepcialcss'; } else {echo 'regularcss'; }">

Done in PHP

As you added the tag, php would do this, actually any language will do.

Generally you have two ways to do this.

  1. Do it on your server.
  2. Do it on client's computer.

for the first way, you check the cookies and generate the page you want.
for the second way, you need to arrange the page the visitors see with java script .

way 1 recommended, coz it loads less bits. LOL

Update:

your server supports php right? the page, say it index.php , has a special area which is different when the visitors login the first time, right?

<?php
    if (firstLogin()){
        genSpecial();
    }
    else{
        genRegular();
    }
?>

in the funcition firstLogin() , you shall read the cookies and determine.
in the other two functions, just gen two different part, ie some html source code.
to your question, if you need to load some image, do it in genSpecial() . and if you choose the first way, js is not used to gen the special area, it's used only if in the special area, there needs some js.

It is possible through javascript. Once the user is shown the settings, store the result in a cookie valid for as long as you want. The next time the user logs in, verify if the cookie is set and then proceed.

Sample code to create cookies:

function setCookie(c_name,value,exdays)
{
   var exdate=new Date();
   exdate.setDate(exdate.getDate() + exdays);
   var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
   document.cookie=c_name + "=" + c_value;
}

Refer this for more details on how to create and use cookies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM