Recaptcha throws Invalid Domain if put in nested iFrame / iFrame inception - iframe

I have a page (page A) that have a popup/modal (page B) for users to input something. The Page B must be rendered by iframe since Page B has its own styling. I would like to put the google reCAPTCHA on the page B to let user verify before input anything.
If I only check Page B, the reCAPTCHA works fine. If page A render page B not using iframe, the reCAPTCHA works fine (but page B is messed up with jQuery conflicts). But, if Page A renders Page B using iFrame, the reCAPTCHA shows
ERROR for site owner:
Invalid domain for site key
This belongs to nested iFrame but what if we have no control of the inner iFrame? Is there any solution to use reCAPTCHA in page B? All ideas appreciated!

Related

Stuck in iFrame, how to get out?

I'm using ASPX web pages (WebPage1.aspx) and have an HTML iFrame defined in this page. I dynamically define the iFrame src (via code behind) when my ASPX web page loads ... all good so far.
The web page that gets loaded into my iFrame supports a "ReturnURL" that I've defined when I set the src for the iFrame. Something like:
src = "https://www.someothersite.com/Somewebpage.aspx?ReturnUrl=http://www.mywebsite.com/WebPage2.aspx"
The web page (Somewebpage.aspx) has a "Return" button, the user clicks the Return button and they should get redirected back to the "ReturnURL" I specified (http://www.mywebsite.com/WebPage2.aspx).
What happens is http://www.mywebsite.com/WebPage2.aspx gets displayed in my iFrame on http://www.mywebsite.com/WebPage1.aspx. This IS NOT what I wanted, I wanted to simply be return to http://www.mywebsite.com/WebPage2.aspx.
Is there a solution to this problem within the context of ASPX and code behind?
Cheers, Rob.

When main page is refreshed (with F5) inner iframe location is missing

I set a src attribute of an iframe as a home page, so after login we redirect the user to the home page.
When the user navigates around it is fine, but the problem comes when the user uses the F5 key on the keyboard as a refresh button.
It refreshes the entire page, which kicks them back to the main page (home page which was set as the src in iframe).
So, I have put the last visited page url in a session variable. But a problem occurs when the last visited page url uses the post method. Then just putting the url in the iframe src does not work as the form has method=post.
this is a common post problem, not related to iframe actually. this is the method i use to prevent this issue:
use posted data (store it to database etc.) and immediately redirect to another page before showing anything on screen. if some data needs to be used on the next page, read it from stored place or use either session or get method to pass to the next page.
that way, you won't have any problems with refreshing the page. you can also store the next page's url to the session variable at the posted page.

stop cross-domain IFRAME links to open in "_top" target

My page loads an IFRAME with content from another domain (and I don't have control over the content) that contains links with target="_top" attribute. My page gets completely replaced once the user clicks on one of these links. Since my page is a stateful web application it would confuse the user.
Is there a way/trick to stop those IFRAME links to do so? They should either (visually) load within the IFRAME or open in a new window.
I don't want to proxy the IFRAME using a server script and alter the HTML code since this would block any user cookies for the foreign domain.
Perhaps some special trick like nested IFRAMEs or whatever could do this?

Stop Master page refreshing while navigating between pages?

I'm using Master Page in my ASP.net application, in the master page I put a ContentPlaceHolder in Update Panel to support AJAX in child pages, the question is how to stop Refreshing "master page controls" while navigating between pages?
For navigation between pages I tried to use Response.Redirect, windows.location java script with no success, shall I use the Frames or IFrames instead of Master Pages to stop Refreshing?
any suggestion to solve this issue will be highly appreciated, Thanks in advance...
If you don't want the page to refresh when switching between "pages", you will not have any good solution using master page. As others have said in different words, the master page is just a common "template" that is used by different pages. The navigation between is just like calling different pages, and of course will reload the entire page, including the master page content.
A sollution I have used with Ajax is
to have each "page" as a user
controls, and put them all in an
UpdatePanel with visible="false".
Then for navigation between "pages", switch
visibility for the user controls
to show the right "page" control.
The alternative is to use iframe.
Neither of these solutions use MasterPage.
The MasterPage concept was designed to simplify a common look before Ajax was introduced in ASP.NET. After Ajax became popular, the demand for not refreshing the entire page has been more common.
A masterpage is nothing more than extending your "normal" page with (most of the time) the default layout of your application. The master page and the contentplaceholders are rendered as a full html page. When you navigate between pages it is the normal behavior that your whole page refreshes. This is how the web works.
Working with an iframe could solve your problem. However that has some other side effects:
The whole masterpage isn't useful anymore. The content around your iframe is the "masterpage".
With a masterpage you actually browse to another url, you also see in the url bar of your browser. When you work with an iframe you navigate within the iframe to another page. The url in your browser will stay the same. When the user of your application hits the refresh button it always starts again at the default page you assigned to your iframe in the html. Of course there are some workarounds
Anyway. It really depends on your application. There are multiple solutions to work around the refresh behavior.
Having a structure like the one you've explained:
Master
Child page 1
Child page 2
...
Then you cannot prevent the page from refreshing when you switch from page 1 to page 2 etc. for you have a single "page" entity (master content + selected page content) when it's rendered to the browser.
If you want to switch betweent different app views inside the very same page (so to prevent a complete page refresh) you could use a single page (the Master becomes quite useless) with an updatePanel in which you load the different views.
You can also use iFrames, but if you have to handle any type of communication between different parts of the page (some of which are inside iFrames) I would personally advice not to use them.

How to get the url of the page which is currently loading in the iframe

I have an requirement that, in my application on clicking an button I have to load one more application with the same template which I was using for my application.
So, on clicking the button in my application I have used one intermediate page in that using iframe I passed that URL of an external application. Its working fine.
But the problem is in the external application which is not in my control on clicking an button it is moving to next page. In that page I want to hide an button.
I did that also using div tag color as white and set the positions.
But the problem is in all the pages in the same position that is affecting. So I want to get the URL of the page which is loading in the iframe on the second or third click of an external application, so that I can using some conditions I can hide the control.
You can use Javascript. Give the iframe an ID
var iframe = document.getElementById(id);
The url is accessible via the "src" attribute:
iframe.src
more info

Resources