My scenario is I have a page name UserMain.aspx
and in this page I have 2 sections (ie2 IFrame
s). Now from one of the IFrame
pages I want to get parentUrl
(ie www.xyz/UserMain.a开发者_高级运维spx
). I have tried the Request.url
but it's giving the url of IFrame
, how to get the parentUrl
?
Both IFrame
and parent pages are on same domain.
You could try using the following. I tried it in one of my solutions but it was not quite what I needed. Maybe it will help you
Request.UrlReferrer.OriginalString.ToString();
The different windows and iframes only exist in the browser, the server code has no means to navigate between them.
In clientscript you can access the URL of the parent window, given of course that the page and iframe is from the same domain:
var parentUrl = window.parent.location.href;
string UrlBrowser= Request.UrlReferrer.OriginalString;
you can do this through client-side script using window.parent.location.href
. This works in case you have an iframe at first level inside a loaded page. If you have more levels of hierarchy, like iframe within iframe ... then you can use window.top.location.href
.
window.top always gets you to the topmost parent window.
精彩评论