Dojo Dialog and iframe

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Dojo Dialog and iframe

Florian Rosenberg-3

hi,

I have the following problem where I'm not sure whether it is related to Dojo or not. I have a Dojo dialog that shows an iframe in it. The dialog opens upon clicking a link on my main page and dynamically sets the source of the iframe (using dojo.io.iframe.setSrc("...")). This works great so far and was pretty easy to achieve. The basic code can be seen at the end of this mail.

Unfortunately, some pages that are displayed within the iframe in the dialog might have a redirect when they are loaded. When this happens, this redirect leaves the iframe and my whole Dojo dialog and opens in the current browser window. Is there any way to get around it? Is it a Dojo + iframe issue or just an issue with the iframe itself that is cannot handle redirect within it (and thus opening by leaving the iframe).

Thanks,
-Florian


Here is the code. In the example I use a proxy to load http://www.gmail.com - as it "nicely" demonstrates my redirect problem in the iframe ;). I'm using Dojo 1.2b0 but it is the same behavior as in v1.1:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Testpage</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
@import "./js/dijit/themes/tundra/tundra.css";
</style>
<script type="text/javascript" src="./js/dojo/dojo.js"
djConfig="parseOnLoad: true, isDebug:false">
</script>
<script type="text/javascript">
<!--
dojo.require("dojo.parser");
dojo.require("dojo.io.iframe");
dojo.require("dijit.form.Button");
dojo.require("dijit.Dialog");

var dlg;
function iframeInit() {
dojo.byId('dialog0').style.visibility = "visible";
dojo.byId('iframeDiv').style.visibility = "visible";
if (!dlg) { // check if it already exists
dlg = new dijit.Dialog({ title:"A nice dialog", bgColor:"black",
bgOpacity:"0.5", toggle:"fade",
toggleDuration:"250" }, dojo.byId("dialog0"));
continueBtn = new dijit.form.Button({label: "Continue", onClick: closeFrame},
dojo.byId('continueBtnDiv'));
}
dojo.io.iframe.setSrc(dojo.byId("serviceFrame"), "/proxy?url=http://gmail.com", true);
dlg.startup();
dlg.show();
}

function closeFrame() {
dijit.byId('dialog0').hide();
dojo.byId('authorizeDiv').style.visibility = "visible";
}
-->
</script>
</head>
<body class="tundra">
<p>
Click <a href="javascript:iframeInit();">here</a>
</p>
<div id="dialog0" style="visibility: hidden;">
<div id="iframeDiv" style="visibility: hidden;">
<iframe id="serviceFrame" src="js/dojo/resources/blank.html"
style="width: 650px; height: 400px; border: 1px solid;">
Your browser does not support <a href="http://en.wikipedia.org/wiki/IFrame"
target="_blank"><code>iframes</code></a>.
</iframe>
</div>
<div id="continueBtnDiv" style="visibility: hidden;"></div>
</div>
</body>
</html>
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
[hidden email]
http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest

Reply | Threaded
Open this post in threaded view
|

Re: Dojo Dialog and iframe

James Burke
On Fri, Sep 12, 2008 at 6:48 AM, Florian Rosenberg <[hidden email]> wrote:
> Unfortunately, some pages that are displayed within the iframe in the dialog
> might have a redirect when they are loaded. When this happens, this redirect
> leaves the iframe and my whole Dojo dialog and opens in the current browser
> window. Is there any way to get around it? Is it a Dojo + iframe issue or
> just an issue with the iframe itself that is cannot handle redirect within
> it (and thus opening by leaving the iframe).

This normally means your target page (www.google.com in this case)
probably does not like being in an iframe, detects the iframe, and
tries to pop out of it. I do not expect that normal HTTP 301 or 302
redirects to cause this problem.

James
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
[hidden email]
http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Dojo Dialog and iframe

Sourya
This post has NOT been accepted by the mailing list yet.
In reply to this post by Florian Rosenberg-3
Hi Florian,
Were you able to resolve this? i'm having the exact scenario where the redirect leaves the iframe and open in the current browser window. Appreciate your help on this.

Thanks & Regards,
Sourya