简体   繁体   中英

Load different pages while leaving certains divs behind

I want to know how some web pages move between different PHP pages without reloading the entire page. Here some divs stays the same. If I use AJAX i cannot share the link of the page, so I need to do this. Thank you.

You have to use AJAX in order to do that. BUT if you want to be able to share the link or handle reload ou need to build a navigation system using # and some javascript around it.

There is a lot of example for doing that on the web.

https://www.google.nl/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=tutorial%20build%20ajax%20navigation

You could just load a new page and include the same divs of the page :

include 'div1.php';

You could use the other answers below and just use ajax but also build a url at the same time so you can navigate back to the same structure of the page. clicking the link modifies the url, eg:

document.title = document.title + '?div1=true'

Modify the URL without reloading the page

and then just does an ajax call to load a new section. And on first page load, parse the url to check what divs to load.

you could use iframes:

<iframe src="/div1.php" id="div1"></iframe>

And clicking a link loads new stuff to a specific iframe.

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