Restricting my site to use other domains url in iframe
How I restricting my site to use other domains url in iframe.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Priti KumariPosted Apr 17, 2014, 4:23 AM
Priti KumariPosted Apr 17, 2014, 4:22 AM
Vivek AryaPosted Apr 17, 2014, 3:54 AM
AshishPosted Apr 17, 2014, 3:44 AM
you can do this by inspecting the referer property.
Request.UrlReferrer
See that it contains the domain that you want to allow. This property is available when an embedder puts your page in the IFRAME's SRC attribute and the
page loads for the first time
AshishPosted Apr 17, 2014, 3:36 AM
if (window.top.location.host != "mydomainname")
{
document.body.innerHTML = "Access is not allowed";
}
ADD above javascript in your code and tell me .....
Priti KumariPosted Apr 17, 2014, 3:33 AM
Priti KumariPosted Apr 17, 2014, 3:27 AM
AshishPosted Apr 17, 2014, 3:19 AM
My Site Scene is like this:
when i load my web page then my url is like:http://mydomainname/page/mypage.aspx
in mypage.aspx one iframe, in this iframe my another page load dynamicaly according to user click on some specific link.
so my parent url http://mydomainname/page/mypage.aspx not change but my iframe page is change every time according to user click.
Case 2:
In above condition when i add another site url to my iframe src then its load another site to my web site iframe.so i want to restrict this .
Q1) Is your Case 1 working ?
Q2) When you want to restrict another site url in your Iframe, then why are you setting src to that site. ?
Because its browser feature to show the requested page in Iframe.
Priti KumariPosted Apr 17, 2014, 3:06 AM
Priti KumariPosted Apr 17, 2014, 3:05 AM
AshishPosted Apr 17, 2014, 3:00 AM
Am i right?
Working on this give me some time.
Priti KumariPosted Apr 17, 2014, 2:51 AM
when i load my web page then my url is like:http://mydomainname/page/mypage.aspx
in mypage.aspx one iframe, in this iframe my another page load dynamicaly according to user click on some specific link.
so my parent url http://mydomainname/page/mypage.aspx not change but my iframe page is change every time according to user click.
In above condition when i add another site url to my iframe src then its load another site to my web site iframe.so i want to restrict this .please help me......
AshishPosted Apr 17, 2014, 2:44 AM
Thanks,
Ashish
Priti KumariPosted Apr 17, 2014, 2:21 AM
AshishPosted Apr 17, 2014, 1:38 AM