PDA

View Full Version : Problem ragarding Iframe .........



cruxer
2 Feb 2007, 2:30 AM
Hello Friends,
Hope You guys can giude me !!

In my application I am trying to load a page inside a dialog. I used iframe .I am putting my code below. Help me to sort it out !!!






<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Layout Dialog Example</title>
<script type="text/javascript" src="javascripts/yui/build/utilities/utilities_2.1.0.js"></script>
<script type="text/javascript" src="javascripts/yui-ext/yui-ext.js"></script>
<link rel="stylesheet" type="text/css" href="javascripts/yui-ext/resources/css/yui-ext.css" />
<script language="javascript" src="layout.js"></script>
<link rel="stylesheet" type="text/css" href="../examples.css" />
</head>
<body>
<div class="example-info">
</div>
<input type="button" id="show-dialog-btn" value="show-dialog"/>

Here can i pass the link to open in dialog ?
<div id="hello-dlg" style="visibility:hidden;">
<div class="ydlg-hd"></div>
<div class="ydlg-bd">
<div id="center" class="ylayout-inactive-content"></div>
<div id="west" class="ylayout-inactive-content">
</div>
</div>
</div>
</body>
</html>

Js how i craeted iframe



dialog.addKeyListener(27, dialog.hide, dialog);
dialog.addButton('Submit', dialog.hide, dialog);
var layout = dialog.getLayout();
dialog.beginUpdate();
layout.add('west', new YAHOO.ext.ContentPanel('west'));
layout.add('center', new YAHOO.ext.ContentPanel('center', {fitToFrame:true, autoCreate: {tag:'iframe',src:"http://mypage.html", id:'cpMain', name:'cpMain',frameborder:'no'}}));
dialog.endUpdate();

hcristea
2 Feb 2007, 2:54 AM
so when your dialog appears (after calling the show() method) the IFRAME is empty? this is what you are saying?

if this is the behaviors then probably you should update the SRC of your iframe after you displayed the dialog.

have you tried to put the IFRAME in the markup?

I. put the IFRAME in the center div markup


<div id="center" class="ylayout-inactive-content">
<iframe id="cpMain" frameborder="no"></iframe>
</div>

and then when you show the dialog to do something like this:


dialog.show();
getEl('cpMain').dom.src = 'http://mypage.html'

or set the src of the iframe with a delay (until the dialog finishes the animation)

dialog.show();
var dt = new YAHOO.ext.util.DelayedTask();
dt.delay(200, function() { getEl('cpMain').dom.src = 'http://mypage.html'; });

II. Instead of a <div id="center" ... /> use directly the IFRAME


<iframe id="cpMain" frameborder="no"></iframe>
<div id="west" class="ylayout-inactive-content">....</div>

the your js will change like this:


...
layout.add('center', new YAHOO.ext.ContentPanel('cpMain', {fitToFrame:true}));
...


then change the src of the iframe as shown in suggestion I.

curious
2 Feb 2007, 3:32 AM
wow
Its working now.Thanks a lot friend.

One more thing i wnat to sort it out . I want to load my dialog along with a page . here i dont hav any butten to call dialog. I want to see my dialog when i load my page !!!!!!!
your suggessions are very helpfull to me.

tryanDLS
2 Feb 2007, 7:11 AM
Look at the examples. For the most part they all start the process onDocumentReady, not a button click.