用户进入网站时动画,但旅行时不动画
我有一个网站,我想在页面加载时使用一些简单的动画。动画代码没有问题。该动画是菜单和其他元素的淡入。我将其称为我的页面的介绍。我希望最终用户仅在访问网站时看到此动画,而在单击菜单中的某些链接并浏览我的网站时看不到。我现在通过仅将动画代码放在前端页面来解决这个问题,但例如:如果有人向某人提供 mywebsite.com/news 的链接怎么办?他将进入网站,但不会看到动画,因为它只出现在首页上。有什么解决办法吗?我想一些会议& cookies“if”语句可能与php一起使用,但我是初学者,我不知道如何解决。
I have a website, where i wanna use some simple animations when the page is loaded. The animation code is not a problem. This animation is some fading in of menu and other elements. I will call this an intro of my page. I want the end-user to see this animation ONLY when he visit a site, and dont see when he clicks some links in menu and travel around my website. I worked it out for now by putting the animation code only on fron page, but for example: what if someone gives a link to mywebsite.com/news to someone. He will go into site and he will not see the animation cause its only on the front page. Any solutions? I think about some session & cookies "if" statements with php maybe, but I'm a begginer and I dont know how to work it out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使您的主页始终相同,只需加载其他页面的代码即可。我的意思是,您可以使用框架或带有 include('file.php'); 的 php 代码。例如。然后,您的动画将始终位于同一页面上,或者仅在网站的每个页面中加载一个框架,并在该框架中加载动画。
Make your home page always the same, and just load the code of the other pages. I mean, you can use frames, or php code with include('file.php'); for example. Then your animation will be always on the same page, or just load a frame in every page of your site, and the anim in that frame.
您要求您的系统(作为一个整体)记住 HTTP 请求(页面获取)之间的信息。 HTTP 在设计上是一个无状态系统,因此您必须使用为记住信息而开发的机制之一:cookie 或(服务器端)会话。 (实际上,会话通常是使用 cookie 实现的,但您可以将它们视为单独的技术)。
PHP 中的会话非常易于使用:您只需在创建新会话时触发动画即可。但您必须弄清楚如何决定会话何时继续,以及会话何时过期而您需要新的会话。
You are asking your system (as a whole) to remember information between HTTP requests (page fetches). HTTP is by design a stateless system, so you will have to use one of the mechanisms which have been developed for remembering information: cookies or (server-side) sessions. (Actually, sessions are usually implemented using cookies, but you can think of them as separate technologies).
Sessions in PHP are quite easy to use: you'll just fire the animation when you create a new session. But you will have to work out how you are going to decide when a session is continuing, and when it has expired and you need a new one.
要销毁一个 php 会话,您可以执行
session_destroy();
To destroy one php session you can do
session_destroy();