javascript - How to show welcome message only onetime when visit the home page? -
i working rails applications since couple of months. supposed add together feature show welcome message first time when user visits site home page, , not sec time user reloads same page.
how can accomplish using jquery or javascript?
simply set cookie , check it. if utilize 1 of usual jquery cookie plug-ins, set script @ bottom of page:
(function($) { if (!$.cookie("yourcookiename")) { $("selector message").show(); $.cookie("yourcookiename", "x"); } })(jquery);
that looks cookie and, if not found, shows content you've defaulted beingness hidden.
it's not perfect, because user can clear cookies, it's enough.
javascript jquery ruby-on-rails
No comments:
Post a Comment