I want to show an external site in an iframe. But I'm getting this error: "This content is not displayed in a frame".
<div id="frameDiv" style="height: 900px;">
<iframe id="leftFrame" src="<%=leftLink%>" width="100%" height="100%" name="leftFrame"></iframe>
</div>
I also use it as a meta tag:
<meta http-equiv="X-Frame-Options" content="SAMEORIGIN" />
Thanks.
-
There is an IE security setting, since you are loading external websites IE might stop this. Tools --> Internet Options --> security --> Internet Zone --> Custom Level --> Miscellaneous --> Launch programs and files in an iframe. with other browser Read the warning text - The publisher (google) does not permit hosting their site in an iframe or frame. Google does this by adding a http header, "X-FRAME-OPTIONS: DENY" which modern browsers will - and should - obey. developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_headerAmit Mishra– Amit Mishra2017年01月04日 11:54:15 +00:00Commented Jan 4, 2017 at 11:54
-
So I can not use an iframe in Chrome?mr.android– mr.android2017年01月04日 11:58:44 +00:00Commented Jan 4, 2017 at 11:58
-
The site you are displaying in the iFrame, is it a site you own, or something out in public domain?Eric Burdo– Eric Burdo2017年01月04日 12:59:00 +00:00Commented Jan 4, 2017 at 12:59
-
It is a site used internally but in another domain.mr.android– mr.android2017年01月04日 13:02:20 +00:00Commented Jan 4, 2017 at 13:02
2 Answers 2
try this
<iframe name="myIframe" id="myIframe" width="400px" height="400px" runat =server></iframe>
Expose this iframe in the master page's codebehind:
public HtmlControl iframe
{
get
{
return this.myIframe;
}
}
Add the MasterType directive for the content page to strongly typed Master Page.
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits=_Default" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
In code behind
protected void Page_Load(object sender, EventArgs e)
{
this.Master.iframe.Attributes.Add("src", "some.aspx");
}
1 Comment
I've tried this solution and its useful in my problem:
Open Internet Explorer and select "Tools> Internet options".
Select the "Privacy " tab and select the "Advanced" button.
An "Advanced Privacy Settings" window will open.
Tick the "Override automatic cookie handling" button and "OK" back to Internet Explorer.
Now try your problem website.