简体   繁体   English

如何在首页加载时使jQuery弹出消息?

[英]How to make jQuery popup message on first page load?

I'm working in a web application using ASP.NET in C#, I wanted to implement a popup message to inform user that new features is available, it is similar with Facebook new feature message. 我正在使用C#中的ASP.NET在Web应用程序中工作,我想实现一个弹出消息以通知用户新功能可用,这与Facebook新功能消息相似。

The popup should be trigger only in home page and first time load by users, the location of the popup message is fixed and it should be gone when page scroll to bottom. 弹出窗口应仅在主页上触发并由用户首次加载,弹出消息的位置是固定的,并且当页面滚动到底部时应该消失。

My problem is how can I track the page load is home page and is the first time for the user? 我的问题是如何跟踪主页的页面加载以及用户首次访问? and any jQuery plugin able to help on the popup message? 以及任何能够帮助弹出消息的jQuery插件?

Thank you in advanced. 在此先感谢您。

You can do an ajax request that calls a controller that creates a session indicating that it is the first page load. 您可以执行ajax请求,该请求调用一个控制器,该控制器创建一个会话,指示该会话是第一页加载。

Based on the result , flag the popup. 根据结果​​,标记弹出窗口。

Just google for jQuery popup solutions. 只是谷歌jQuery弹出式解决方案。 There are loads of them. 他们有很多。

To show popup only on home page, you can use: 要仅在主页上显示弹出窗口,可以使用:

jQuery(location).attr('href');

And to show it only one time, you can set cookie . 要只显示一次,可以设置cookie

Here is very good plugin for jQuery for cookies: https://github.com/carhartl/jquery-cookie 这是用于jQuery非常好的Cookie插件: https : //github.com/carhartl/jquery-cookie

It lets you set cookie as easy as: 它使您可以轻松设置cookie:

$.cookie("cookieName", "cookieValue");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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