How to grab parent url from iFrame using C #

In my script, there is a page name UserMain.aspx, and on this page I have 2 sections (i.e.2 IFrames). Now from one of the pages IFrameI want to get parentUrl(i.e. www.xyz/UserMain.aspx). I tried Request.url, but he gave the url IFrame, how to get parentUrl?

Both pages IFrameand parent pages are in the same domain.

+3
source share
4 answers

There are only different windows and frames in the browser, the server code does not have the ability to move between them.

clientcript URL- , , , iframe :

var parentUrl = window.parent.location.href;
+5

. , , . ,

Request.UrlReferrer.OriginalString.ToString();
+9
string UrlBrowser= Request.UrlReferrer.OriginalString;
+1

script, window.parent.location.href. , iframe . , iframe iframe..., window.top.location.href.

window.top .

0

Source: https://habr.com/ru/post/1763436/


All Articles