thunx jaredn, but i knew it. actually, i want 2 get html code from iframe & put it into the layer (div). but this code works only with *static* source.
my problem is:
when i change the frame's content (load another file) i cant get this new document's body - its empty, & so, all elements returned as *undefined*
(now i used this function with your code, thought it wuld help me... - nope : )
function doit(){
ifra=document.all.iframename
ifra.src='newfile.htm'
iframedoc = self.frames.iframename.document
el = iframedoc.all.body
alert(el+' '+el.innerHTML) //<---first time body.innerHTML is empty, but the second time - all works
//+el.innerHTML)
//getElementById("elementid"
//el.innerHTML = "whatever <b>you</b> want"
}
but
(if) when i call this function twice, it works: document object of this new file is not empty, & i can get whatewer i want, like u said
what shuld i do 2 get it 2 work from first time???
function doIt(){
ifra=document.all.iframename
ifra.src='newfile.htm'
checkint = setInterval(checkIfReady,10)
}
function finishIt()
{
ifra=document.all.iframename
ifra.src='newfile.htm'
iframedoc = self.frames.iframename.document
el = iframedoc.all.body
alert(el+' '+el.innerHTML) //<---first time body.innerHTML is empty, but the second time - all works
//+el.innerHTML)
//getElementById("elementid"
//el.innerHTML = "whatever <b>you</b> want"
}
function checkIfReady()
{
var doc = self.frames.iframename.document;
if(doc)
{
if(doc.readyState=='complete')
{
clearInterval(checkint)
finishIt()
}
}
}
}
I didn't test any of it, but that should giv eu a starting point. jared@eae.net -
Hi guys!
I think i did it! Well, if someone is interested, here is the code:
<script>
function doIt(fil){
ifra=document.all.iframename
ifra.src=fil
setTimeout('waitin()',0)
}
function waitin(){
if (frames.iframename.document.readyState == 'complete') { setTimeout('puting()',0) }
else setTimeout('waitin()',10)
}
function puting(){
var obj=self.frames.iframename.document.body
document.all.Layer2.innerHTML=obj.innerHTML
}
</script>
& there also must be iframe called iframename on the page and layer called Layer2
<div id="Layer1" style="position:absolute; left:423px; top:71px; width:300px; height:27px; z-index:1; ">
<form>
loadin file1<input type=button value='click here' onclick='javascript:doIt("file1.htm"' ><br>
loadin file2<input type=button value='click here' onclick='javascript:doIt("file2.htm"' >
</form>
</div>
<div id="Layer2" style="position:absolute; left:12px; top:368px; width:661px; height:140px; z-index:2">
<center><strong><font color='red'>here the new content will appear (may be, on the 2nd time)</font></strong></center>
</div>
<iframe style="display:block" name=iframename id=iframename src=""></iframe>
style="display:block" – just 2 see that content HAS been loaded; u can hide this iframe, and this eggzactly is what i was doin it for.(sorry for my english)
try it yourself, i got it to work on my computer, (win98, ie5.0) as for now i cant upload it on the NET, ‘coz my connection is xtrmly slow. Culd u guyz check it & tell me if it doesnt work on Inet?
And btw, culd anybody xplain me, why am i 2 use such construction setTimeout('puting()',0) – without it it doesnt want 2 work properly (& like i told before, without this stuff it works only from the second attempt)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.