简体   繁体   中英

Load PHP include only when div is in viewport

i read and search but i don´t get it. :( I have a HTML-site with a lot of data. So i only want this:

  • Load a included PHP/HTML file thats visible when i open the page (Yes, it should be a included file with some code)
  • If the end of the page is reached, the next included PHP/HTML file should be "loaded and visible" - Yes it should ONLY loaded when the div with the included file should be visible
  • And so on

For example:

<html>
<head>
<javascript code to load and check the visible of the divs>
</head>
<body>
<div id="i am visible because i am in the vieport>Some content</div>
.
.
.
<div id="i am the next div with included content, but i am not in the viewport on start, only when a user is scrolling><?php include 'somefile.php'; ?></div>
.
.
.
<div id="i am the next div with included content, but i am also not in the viewport on start, only when a user is scrolling><?php include 'somefile2.php'; ?></div>
.
.
</body>
</html>

Please can anybody help me. I am good at php, but i don´t understand javascript so good :(

Thanks, RonnyDee

What you are asking for must be done with client-side code, this means code that is executed on the client side (the user's browser). You have to use for example JavaScript for this. This cannot be done with PHP on the server-side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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