Re: Referncing a JS generated iframe
"Michel Carroll" <[email protected]> Wed, 17 May 2006 22:24:49 -0000
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
Hi Pan,
sorry I've not got back sooner!
I can give you an example, but I'll have to edit it down for clarity.
the main page contains a holding div with another div that contains an
iframe:
<div id="dvTop" class="dvfr">
<div id="dvFr0" class="dvfr" style="display: block">
<iframe id="fr0" src="" height="100%" width="100%"
frameborder="0" onload="loaded(this)"></iframe>
</div>
</div>
I have an array of page sets I might need to load:
var sets={
"choose":["list.aspx","details.aspx"],
"craft":["pageManager.aspx","versionManager.aspx","gManager.aspx","audience.aspx","selectEdit.aspx","viewEdit.aspx","bulkEdit.aspx"],
"report":["parameters.aspx","results.aspx","layout.aspx"]
}
var curSet;
and I have a function which loads these pages in sets:
function loadSet(set){
if(set!=curSet){
curSet=set
carnet=getEl("dvTop")
sheets=carnet.getElementsByTagName("div")
frmModel = sheets[0].cloneNode(true)
for(i=sheets.length-1;i>=0;i--){
carnet.removeChild(sheets[i])
}
for(i=0;i<sets[set].length;i++){
clnSheet = frmModel.cloneNode(true)
clnSheet.id="dvFr"+i
clnSheet.style.display="none"
ifr=clnSheet.getElementsByTagName("iframe")[0]
ifr.id="fr"+i
ifr.src=""
carnet.appendChild(clnSheet)
frames[i].location.replace("../scheduling/"+sets[set][i])
}
carnet.getElementsByTagName("div")[0].style.display="block"
frames[0].location.replace("../entry/"+sets[set][0])
}
}
that's it
Any more questions - feel free to ask
Cheers
Michel
--- In [email protected], "js pan" <javascript.pan@...> wrote:
>
> Hi Michel,
>
> Can you show some working example? Thx
>
> pan
>
> On 4/20/06, Michel Carroll <yahoo@...> wrote:
> >
> > What you say here doesn't tally with my experience. I regularly
insert
> > iframes through the DOM (using cloneNode) and their documents are all
> > available through the frames collection (as in
> > frames[i].document.getElementById(...)).
> >
> > Could you be more explicit as to what you mean by "generate an iframe
> > on the fly"?
> >
> >
> > Michel
> >
> >
> > --- In [email protected], "Seb Frost" <seb@> wrote:
> > >
> > > If you generate an iframe on the fly it doesn't get entered into the
> > > frames[] array, so you can't use that.
> > >
> > > So I'm left with document.getElementById('myiframe'); That
correctly
> > > returns an object.
> > >
> > >
> > > But if I have an element of ID "foo" inside that iframe how do I
> > reference
> > > that?
> > >
> > > document.getElementById('myiframe').document.getElementById('foo');
> > >
> > > doesn't seem to work. The second ".document" in that line of code
> > seems to
> > > give a reference back to the main page's document element, not the
> > one for
> > > that iframe. I've tried lots of things, but don't seem to be
getting
> > > anywhere!
> > >
> > >
> > > This is a problem I've come across implimenting "the man in blue"'s
> > > widgeditor.
> > >
> > > cheers,
> > >
> > > - seb
> > >
> >
> >
> >
> >
> >
> > Unsubscribe
> > [email protected]
> >
> > List info
> > http://www.quirksmode.org/dom/list.html
> >
> >
> > ------------------------------
> > YAHOO! GROUPS LINKS
> >
> >
> > - Visit your group "wdf-dom
<http://groups.yahoo.com/group/wdf-dom>"
> > on the web.
> >
> > - To unsubscribe from this group, send an email to:
> >
[email protected]<[email protected]?subject=Unsubscribe>
> >
> > - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service <http://docs.yahoo.com/info/terms/>.
> >
> >
> > ------------------------------
> >
>
>
> [Non-text portions of this message have been removed]
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/9rHolB/TM
--------------------------------------------------------------------~->
Unsubscribe
[email protected]
List info
http://www.quirksmode.org/dom/list.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wdf-dom/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/