0

I have a page that is loaded inside. The application including this page is located on another domain. So the domain of my page and the application rendering it inside an iframe are located on different domains. The page inside iframe reads the URL it is loaded from to store in the database. The page loading has a hash in the URL.It is like:

https://www.somedomain.com/organizers/list/#type=current&sort=bydate

I am reading the URL from mypage. It is located on: https://www.someotherdomain.com/organizers/#sample

var _url = document.referrer

The above code gives me the URL but only till "https://www.somedomain.com/organizers/list/", "#type=current&sort=bydate" is missing. I need that else this code is of no use to me. Is there a way I can read the complete URL without missing any segment?

user1640256
  • 1,691
  • 7
  • 25
  • 48
  • 2
    Possible duplicate of [Send a location hash through a referrer](https://stackoverflow.com/questions/2039306/send-a-location-hash-through-a-referrer) – Koby Douek Aug 16 '17 at 16:52
  • @KobyDouek that question is regarding sending the URL to server with hash part. My question is to read the URL without leaving a thing. – user1640256 Aug 16 '17 at 17:03

2 Answers2

0

like this
var _url = window.location;

Fatehi_Alqadasi
  • 548
  • 5
  • 14
0

This is by design. The browser will give you the referrer which is the URL where the user came from, however the #hashmark is technically (by its original design) a sub-navigation concept within a page, thus not passed on to the next page load.

If you were on the same domain as the parent page, you could access it via the

window.parent.location.hash

however since you are from a different domain this access will likely be blocked for security reasons.

scunliffe
  • 62,582
  • 25
  • 126
  • 161