Questions on iframr, and on textarea scrolling

  • Thread starter Dr J R Stockton
  • Start date
D

Dr J R Stockton

I'm using an iframe, to load same-domain pages.

Can JavaScript tell if the requested page does not exist, and if so how?
I want to note and continue.

Can JavaScript tell when the page loading is complete, and if so how?
The equivalent of body onload would do, though after the completion of
the page's own body onload would be better. For this purpose, it is
highly desirable that nothing should need to be added to the iframe
pages.

Essentially I want
onCompletelyDoneTheFollowingLine = functionname
iframe.src = URL
}

I have a suspicion that if in at least one browser a "full" page
is loaded in an iframe, followed by a page with less than two
anchors, the second page may not replace the anchors array of
the first page.

Can JavaScript scroll a textarea, and if so how? I have a textarea that
gets new lines appended at a variable rate of about one a second, and
would like to have the newest ones normally visible - just like MSDOS or
an ASR33.
 
E

Evertjan.

Dr J R Stockton wrote on 08 okt 2009 in comp.lang.javascript:
I'm using an iframe, to load same-domain pages.

Can JavaScript tell if the requested page does not exist, and if so how?
I want to note and continue.

<script type='text/javascript'>
function isFound(){
return (window.frames[0].location.href)
? 'found' : 'not found';
};
</script>

<iframe src='myTest.html'
onload='alert(isFound())'
</iframe>

Chrome tested working,
but I don't think IE will like that code.

[Using serverside javascript, it is easy.]
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>
Dr J R Stockton wrote on 08 okt 2009 in comp.lang.javascript:
I'm using an iframe, to load same-domain pages.

Can JavaScript tell if the requested page does not exist, and if so how?
I want to note and continue.

<script type='text/javascript'>
function isFound(){
return (window.frames[0].location.href)
? 'found' : 'not found';
};
</script>

<iframe src='myTest.html'
onload='alert(isFound())'
</iframe>

Chrome tested working,
but I don't think IE will like that code.


In at least one browser, that event fires on loading of the page outside
the frame, which is at that stage empty. So I changed to executing

Fram = document.getElementById("IF") // The iframe

while the outer page is loading (already there, for another reason), and

Fram.onload = ReadFram // A function to read the frame contents

on pressing the "Starting Gun" button.

In Opera (which is where everything else on the page works best) that
event clearly fires at the right time. Previously I used a compromise
300 ms timeout, and a small number of pages were not fully loaded by
then. Now the whole process is much faster (i.e. well under 300 ms
needed on average) but all pages are loaded completely.

Since it is clear that, if timeout is used, it needs to be well over
zero milliseconds, I have arranged to use timeout if non-zero and onload
if not, which allows for Firefox & Safari where onload is not (yet?)
working in the same manner.

I've not got isFound to actually detect anything yet. But there's
always the work-round of loading a missing page to get a sample "404"
for the current system, then looking for a match to it later.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top