dougua3705 2014-06-11 12:47
浏览 31

每次用户访问网页时都会播放视频?

I have created a splash-video which is played when a visitor visits the page for the first time. With a cookie I can set an expiration time when this splash-video will popup again. What I'd like to achive instead is when this splash-video is played on first visit it will only display again on next visit (when user closes the tab or closes the web browser window).

What I have read while searching, if I don't set an cookie expiration this should work.

setcookie( 'my_cookie', 1 );

The problem is that if user in for example Chrome have settings set to "On Start -> Continue where you left off", this behaviuor won't work.

Is there really a bullet-proof way of achieving what I want?

Kind regards Johan

UPDATE:

This seems to work fine. Any comments on that?

<script type="text/javascript">
if (/(^|;)\s*bvssp_visited=/.test(document.cookie)) {
    document.getElementById("demo").innerHTML = "welcome back";
    var myVar=setInterval(function(){document.cookie = "bvssp_visited=true; max-age=" + 10 * 1},1000);
} else {
    var myVar=setInterval(function(){document.cookie = "bvssp_visited=true; max-age=" + 10 * 1},1000);
    document.getElementById("demo").innerHTML = "Hi new user";
}
</script>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
    • ¥20 CST怎么把天线放在座椅环境中并仿真