Back button skipping php pages - php

I have a website that consists of entirely php pages. If you do the following:
Google -> php page1 -> php page2 -> hit the browser back button and you go back to Google
I want the user to get taken back to php page1 instead of Google when they hit the back button on php page2.
I have a feeling this is to do with the automatic scripts, generated by php, that stop the browser caching pages. However, I don't want the pages to be cached as this would stop the content being updated.
Thanks for any advice!

function goToTag(tagid, tagloc){
location.replace("main.php?tagid="+tagid+"&result="+tagloc);
}
Switch it to location.href="main.php?tagid="+tagid+"&result="+tagloc; and you'll be just fine. location.replace does what it says on the tin - it replaces the current history item with the new page.

Related

How to get page source that is loaded through AJAX?

I am using data scrapping technique(Parsing) in php to get the data from a web page using html_dom class. This page has some AJAX method to load more data when we scroll down the page but in page source there is only data that loads first time mean when we browse the page first time.
So my question is how to get the all page source that loads through AJAX??
Thanks
If you are using chrome, you could use developer tool or F12 button. Then go to network tab and tick the preserve log button and select the XHR tab to see which source is being loaded in that page.

identify what webpage URL is opened in php

i have a php page that logs in an account as if the real person is doing it. i would like to put in a php script that checks the webpage URL currently opened. the page works this way:
i run localhost/loginmirror/index.php from my browser.
new browser window is automatically opened. page loaded is the URL of the page i placed on my code (ex: https://twitter.com/).
i use php scripts to put in the username and password and click the Login button. everything necessary for input and clicking is done by
my php code. no human needed. after clicked, i am redirected to the
next page and so on and so on.
i would like to get the URL of the particular page now opened. i have tried using
$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
but it retrieves this: loginmirror/index.php instead of returning which page in google mail is now opened.
how do i get the URL that i want to retrieve? thanks

Working of browser 'back button' using jquery ajax and PHP

I am working on an application which involves lot of ajax requests for updating the HTML content.I have a dashboard with a fix left menu or accordian panel which takes the event and based on the events I have to update the center portion of the page using ajax.
Issue: I am facing issue with the back button of the browser as I am not refreshing the page.I want that the user should be able to navigate back and forth through the ajax content,but as I don't change the URL it redirects the user to the previous page they came from and destroys all the information entered by the user in the fields.
While making a search I came through this website which is quite popular and manages a playlist on the left and a player at the bottom without refreshing the page,but the URL changes for different content the show.
I am not sure if there is any specific framework that can be used or it can be achieved via normal code.Any help in pointing me to the right links or suggestions over it would be helpful.
Thank you
What you seem to want is history.js. It uses the HTML5 history API to navigate (and you can fire events upon change), and it also supports older browsers by using hashbangs.
Essentially the browser will not load any new page, but you can still change the URL to reflect changes (and have the users bookmark pages etc.).
Take a look at their demos to see if it's what you're looking for.

PHP Detect where page is loading from

I've searched and searched google for an answer but could not find one.
I need a PHP script or javascript ( PHP would be better but i don't mind ) to detect if a page is being loaded from SERVERIP/page.php or SERVERDOMAIN.com/page.php.
I have the server IP that does not cache the pages, And i have the domain that caches the pages. I want to make sure that if the page is being loaded from SERVERDOMAIN it gets redirected to SERVERIP so it does not get the cached page.
Example.
I go to SERVERDOMAIN for one page i get the cached page, I then go to another page that does not need to be cached so it gets redirected to SERVERIP.
See if
>$_SERVER['HTTP_REFERER']
works for you.

Detecting when a link has been clicked with PHP

I have built an in browser engine that will retrieve pages without executing server side scripting... seems ridiculous, I know, but I'm doing this as part of a school project.
The problem that I am having is that once it displays the page if a link is clicked it will bring you to www.their-site.com instead of www.my-site.com?site=www.their-site.com.
Basically I need my php page to detect if a link is clicked and, if so, add "www.my-site.com?" before it so that all sites will still be rendered without all the server side scripting. Is their any way to do this?
---------------EDIT---------------------------------------------------------------------------
Ok I guess I wasn't clear enough the first time sorry about that.
I have made a php page that will display the contents of any site without executing the server side scripting that belongs with that page. This allows you to get around those annoying news articles that allow you to have a glimpse at them for two seconds and then a login box appears. the problem is once you've accessed the pages if you click any links you are connected to their server and the scripts turn back on. I want MY php to execute, not THEIRS
You need to know what you want first.
You say no server side scripting, then you mention php.
To do this, I don't think you can do it with just js.
You need to get the pages, using php, depending on what exactly, modify them such that when a link is clicked, it sends an ajax call to another page. This will require either regex replacement or the use of htmldom.
When a link is clicked, it should send the ajax response to the php page which can then request tha page, make modifications and send it back to the browser. You can then use js to replace the page contents.

Categories