Reputation: 812
have something like this: click in page A and redirect to page B, click in page page B redirect to page C, is there any way to get the URL of page A when I am in C page? and check if page A = 'domain.com/aboutus'.
I am not so good in javascript, I try to do this in PHP but is not work very well because the LastURL here is not the page that I want, maybe someone can show me an script example.
if (strpos(Mage::getSingleton('core/session')->getLastUrl(), 'checkout/cart') !== false) {
Mage::getSingleton('core/session')->setIsFromCart('1');
} else {
Mage::getSingleton('core/session')->setIsFromCart('0');
}
if (strpos(Mage::getSingleton('core/session')->getLastUrl(), 'onestepcheckout/index') !== false) {
Mage::getSingleton('core/session')->setIsFromCheckout('1');
} else {
Mage::getSingleton('core/session')->setIsFromCheckout('0');
}
Thank you
Upvotes: 0
Views: 180
Reputation: 405
You can use this.
In page A
<script>
localStorage.setItem('pageA_url', window.location.href);
</script>
In page C
<script>
var pageA_url = localStorage.getItem('pageA_url');
</script>
Upvotes: 0
Reputation: 36
use window location or href in javscript
window.location="your URL";
or
location.href=URL;
Ex.
<script>
window.location="http://www.tutorialspoint.com";
</script>
Upvotes: 1
Reputation: 41
You can store A page url in cookie like this document.cookie = window.location.href; and At page C you can get value form cookies
Upvotes: 0
Reputation: 2516
You can pass the page Url in querystring to C, like http://www.example.com/link/to/page/c?from=link/to/page/a, and then parse querystring to get the from address.
Upvotes: 0
Reputation: 50291
You can use document.referrer
but since you want to check url of page A when you are in page C, the best option will be to use a localStorage
Upvotes: 0