I'm running an c# .net app in an iframe of an asp page on an older site. Accessing the Asp page's session information is somewhat difficult, so I'd like to make my .net app simply verify that it's being called from an approved page, or else immediately halt.
Is there a way for a page to find out the url of it's parent document?
When a page is running inside of an iframe, the parent object is different than the window object. You can still access parent from within an iframe even though you can't access anything useful on it. This code will never cause an error even when crossing origins.
Once id of iframe is set, you can access iframe from inner document as shown below. var iframe = parent. document. getElementById(frameElement.id);
To find in the parent of the iFrame use: $('#parentPrice', window. parent. document).
Only the domain which created the cookie can read its cookie. So you have to read the cookie from within the iframe and then pass it to the parent window. If you don't have access or control over the page in the iframe then there is no way to get the cookie value.
top.location.href
But that will only work if both pages (the iframe and the main page) are being served from the same domain.
To get the URL:
Request.UrlReferrer....
To digest the query string:
NameValueCollection qs = HttpUtility.ParseQueryString(Request.UrlReferrer.Query);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With