What would cause an iframe to keep loading its parent page? - html

So this is quite the odd situation.... I have an iframe on a .cshtml page that is continuously loading the full content of the page that the iframe is on. This is the code for the iframe:
<iframe src="#Url.Content("~/dir/file.html")" width="100%" height="100%" scrolling="yes" />
The directory for the file is correct and the file.html file displays correctly without error when it is opened by itself. Also, I have tried using a different test.html file in place of file.html so the error cannot be within that file. Removing the iframe tag obviously stops this issue from occurring.
The other really interesting part about this issue is that I have a working version of the application that this .cshtml file belongs to and I have compared the corresponding .cshtml files and they are identical so I am really bewildered by this. Has anybody ever experienced a situation like this? The iframe literally just keeps reloading the .cshtml file within the iframe until I tell the browser to stop loading so you end up with a page with an iframe, that has a page withing the iframe, that has a page within the iframe, so on and so forth.

The answer to this question lies within the authentication for the application. When the iframe would make a call to file.html it would receive a redirect back to the .cshtml page which of course had the iframe on it so you can see where the loop comes into play. The solution of course then is to change the security settings to allow it to call to file.html as it needs to be displayed there. Thanks anyway.

Related

How to make iFrame behave exactly as if one were accessing the source site directly?

I am working on a site for a Client and they want to display the following URL in an iFrame:
https://www.vigrxplus.com/ct/3134
If you access that site directly, it will show the Promo code on the source website.
However, if you access that site via an iFrame, it will not show the Promo code on the source website:
https://jsfiddle.net/qc3zvo0b/
<iframe width="100%" height="1000" src="https://www.vigrxplus.com/ct/3134"></iframe>
(Make sure to test the iFrame without prior Cookies from having previously visited the source website directly.)
Attempting to enable all sandbox features for iFrame did not fix this.
The source site also seems to do some kind of redirect.
So how can this be fixed such that the iFrame behaves just like visiting the site directly?

Iframe links not redirecting despite correct syntax (HTA file)

I am trying to embed a website in an HTML application that has links. I've tried this:
<iframe id="frame" application="yes"></iframe>
(I haven't really figured out the size) and it worked, just you can't use links on the page. I would usually just put the code of the webpage into the hta file, but there were some problems with javascript. I need to make a multi-page site, so I need links. Is there a way to embed a website that has links onto an HTML app, and still keep the links working? Thank you for any help.

Prevent iframe from loading "src" page upon refreshing

I'm creating a static website and I am using iframes. The problem is, when I navigate to another page, say for example, this code for the iframe:
<iframe marginheight="0" align=top src="aboutus1.php" frameborder=0 scrolling=no border=0 WIDTH=800 framespacing=0 id="bodyframeid" name="bodyframename" onLoad="autoResize('bodyframeid');>" ></iframe>
The src attribute is pointing to aboutsus1.php. Now, when I navigate to another page, for example, I go to aboutus2.php then I reload the page, it goes back to aboutus1.php which is executed by src="aboutus1.php". My question is, how do I stay on the current page (aboutus2.php) even if I reload the page?
EDIT:
Click here for live example
Click the link above. First page you will see is About CTI. Now, try clicking on Partners menu then refresh the page. It goes back to About CTI page. How do I prevent it from going back to About CTI page when the page reload?
You could store the current page location in a session, and on reload load the url stored in the session. But you'd need some server side technology. In just html you don't store things. You might also be able to use a GET value.
You can't. By reloading the page you are loading a completely new page that just happens to come from the same resource as the previous page.
You can't avoid reloading the iframe when you are reloading the main page, but you can make it reload the same page again.
If you want to load a specific page in the iframe, you need to send information to the main page what to put in the iframe src. You can for example send that information in a query string, or put it in a cookie.
If you have in your iframe the documents from the same domain (same origin), or you can set the Access-Control-Allow-Origin headers on displayed page, you can detect iframe src change, and save the current URL (cookie, localStorage or anything you have), and restore it on page load.

Weird IFRAME issue, page blocks itself from loading

This is a weird one. I'm using the URL "http://www.craigslist.org/about/" as an example here.
I load up that page in my browser and modify it with Firebug. I add the following line right after the body tag:
<iframe src="http://www.craigslist.org/about/" id="frame1" name="frame1" width="100%;" height="200"></iframe>
The IFRAME shows as blank! Now when I load https instead of http in the IFRAME it works. At first I thought maybe craigslist doesn't allow itself to be embedded in an IFRAME at all. Then I tried embedding that same IFRAME code on my website and the frame loads as expected.
It's as if they are blocking you from loading the same page within itself!? Anyone ever seen this behavior before?
UPDATE:
This problem appears to be related to my browser. (Firefox 21) When I try to load any IFRAME that has the same exact URL as the parent frame it fails??

IE7 has issues displaying content from dynamically generated url in <object>

IE7 fails to display any contents in dynamically generated url inside the <object> element. Here's an example for loading pdf documents:
<object data="http://localhost:8080/Documents/Query?Id=document123&Session=1510" width="600" height="400"></object>
The above code will fail to load, however, if I copy and paste the url into the browser's navigation bar, the pdf document will load just fine. If I then manually save the pdf file and replace the object tag with the code below, it works just fine.
<object data="document123.pdf" width="600" height="400"></object>
Is there a work around for this?
It's hard to be sure exactly what the problem is without knowing more about your development platform and possibly seeing some of the code for Query. But my guess is that it's down to the mime type that the server is presenting.
You should send the mime type header as application/pdf.
Just came accross this issue myself.
I don't know if yours was the same problem as mine but if you are using the following:
Response.AddHeader("Content-Disposition", "attachment; filename=...
Remove it, keep the content-type as "application/pdf" but don't assign a disposition, that way it will be processed as an outright file and not as an attachment to be downloaded.