简体   繁体   English

页面过渡,更改URL位置时在div中加载新页面

[英]Page transition, Load new page in a div while changing URL location

I'm familiar with the Ajax/jQuery .load() or php include() which can be used to load other content into a div on a page. 我熟悉Ajax / jQuery .load()或php include() ,可用于将其他内容加载到页面上的div中。

Kindly take a look at this example I've posted: my site with page transitions 请看一下我发布的这个示例: 我的网站具有页面转换

How I've set up this page is, the body is 100% of the screen with no overflow. 我是如何设置此页面的,主体是屏幕的100%,没有溢出。 There is the blue section which is 100% height and the red section which is 100% height positioned 100% from the top. 距离顶部100%的位置是蓝色部分,高度为100%,红色部分为100%高度。 When you click the button the blue div is scaled back and the red div is transitioned to top: 0; 当您单击按钮时,蓝色div会缩小,红色div会过渡到top: 0; .

My problem when you hit the back button, it doesn't go back to the blue section, it goes back to the previous page (blue page). 我的问题是,当您按下“后退”按钮时,它没有回到蓝色部分,而是回到了上一页(蓝色页面)。

My question is how can I set this up so the red div (2nd one) will actually change the url (and load another php page into it using include(); or some other method)? 我的问题是我该如何设置它,以便红色div(第二个)实际上会更改网址(并使用include();或其他方法将另一个php页面加载到其中)? For example when you click the button on the blue page, the red page will show up (with the included content) and the url will change to: davidfateh.com/red . 例如,当您单击蓝页上的按钮时,将显示红页(包含所包含的内容),并且URL将更改为: davidfateh.com/red I realize hitting the back page won't give me the transition, but at least it will go back to the blue page, which is my goal. 我知道点击后页不会给我带来过渡,但至少它将回到蓝页,这是我的目标。

Thanks for looking and for any advice! 感谢您的查询和任何建议! Cheers! 干杯!

So basically you show the same page, just different part of it. 因此,基本上,您显示同一页面,只是页面的不同部分。 That is why hitting the back goes to the previous page, not the previous section, which is actually on the same page. 这就是为什么将后面打到上一页而不是上一页的原因,而上一节实际上是在同一页上。

You can do what you want like this: 您可以这样操作:

  1. Create 2 different php files. 创建2个不同的php文件。 red.php and blue.php red.php和blue.php
  2. In each file have only the part you want. 在每个文件中只有您想要的部分。
  3. the buttons now have to send from one page to the other. 现在,按钮必须从一页发送到另一页。 How to do this, depends on how you implemented your existing button. 如何执行此操作,取决于您如何实现现有按钮。

For example, if the buttons are implemented like forms, use something like this: 例如,如果按钮是像表单一样实现的,则使用如下代码:

<form action="red.php"> in one and <form action="blue.php"> in the other. <form action="red.php">在一个和<form action="blue.php">中的其他。

By pressing the button it will jump from one page to the other. 按下按钮,它将从一页跳到另一页。

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

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