在整个网站的一次导航中仅显示一次弹出窗口 [英] show pop up only once throughout one navigation of the site

查看:71
本文介绍了在整个网站的一次导航中仅显示一次弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用laravel创建的网站.我希望用户在第一次访问我的网站时能够看到一个弹出窗口.

I have a website created using laravel. I want the user to be able to see a popup the first time he comes to my site.

第一次,我的意思是-用户访问我网站上的任何页面(这是第一次),访问网站上的某些链接页面(现在,这些访问不是第一次),在同一页面中打开facebook标签(因此离开我的网站),然后再次在同一标签中打开我的网站(这是第一次).

By first time I mean- the user comes to any page on my site(this is first time), visits some of the linked pages on site(now, these page visits are not first time), opens facebook in the same tab(thus leaving my site) and then again opens my site in the same tab(this is first time again).

弹出一次对话框的基本原因是,在用户浏览站点时不要一次又一次地打扰用户.但是,一旦他离开并再次回来,我想把它当作一次新来访(并再次显示弹出窗口).

The basic reason behind one time popping up is not to bother the user again and again while he is navigating the site. But, once he leaves and comes back again, then I want to treat it like a new visit(and show the pop up again).

我知道我可以用jQuery中的setTimeout()弹出窗口.但是,如何只做一次呢?请注意,该弹出窗口不仅可以显示在首页上,还可以显示在任何页面上(如果是当前访问的首页).

I know I can do popup thing with setTimeout() in jQuery. But how to do it just once? Please note that, the pop can appear on any page(if its first page of the current visit), not only on the home page.

推荐答案

您可以使用document.referrer,并检查上一页是否属于您的域.但是出于安全原因,并非所有访问者/浏览器都会返回此值.

you could use document.referrer, and check if the previous page is one of your domain. But not all visitors/browsers will return this value for security reasons.

所以这是不可靠的.

这篇关于在整个网站的一次导航中仅显示一次弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆