469,289 Members | 2,330 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

getURL and Frames

If I use a getURL to retrieve a file and put the contents in a frame
how can I check if the contents loaded in the frame? I don't want to
see a file not found or any errors.

I have a file that has a date (mmddyy) in the file name. So I want to
take todays date check for the file if it's not there check the next
date and so on until I get the file because the file will be there.

Or is there a way to check if a file is on the web server before
loading it?

Thanks.

Jul 23 '05 #1
5 1179
Here is my sample code. I want to check if there's content in the
frame.

<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">

function load(url,id,width) {

if (window.frames.length > -1)
window.frames[id].location.href = url;
}

</SCRIPT>

</HEAD>

<BODY
ONLOAD="javascript:load('http://www.diamondcomics.com/shipping/shipping_062905.txt','myLayer',400)">

<IFRAME ID="myLayer" WIDTH="400" HEIGHT="400"></IFRAME>

<script language="JavaScript">

var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var a = year.toString();
var myYear = a.substring(2);

var text = window.frames[myLayer].document.value;
document.write(text);

</script>

</BODY>
</HTML>

Jul 23 '05 #2

Sounds to me this is for the server language, whichever you are using.
In PHP is very simple doing a FOREACH over a dir() and using file_exists().

Danny

On Sun, 03 Jul 2005 07:58:51 -0700, <cy****@batomic.com> wrote:
If I use a getURL to retrieve a file and put the contents in a frame
how can I check if the contents loaded in the frame? I don't want to
see a file not found or any errors.

I have a file that has a date (mmddyy) in the file name. So I want to
take todays date check for the file if it's not there check the next
date and so on until I get the file because the file will be there.

Or is there a way to check if a file is on the web server before
loading it?

Thanks.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #3
JRS: In article <11********************@f14g2000cwb.googlegroups.c om>,
dated Sun, 3 Jul 2005 10:19:39, seen in news:comp.lang.javascript,
cy****@batomic.com posted :

var year = (yy < 1000) ? yy + 1900 : yy;


There is or has been at least one browser for which that fails.

You can, for a while, use var year = 2000 + yy%100.

Has anyone checked getYear() on various browsers for years in the
range 2095-2105?

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4
Dr John Stockton wrote:
JRS: In article <11********************@f14g2000cwb.googlegroups.c om>,
dated Sun, 3 Jul 2005 10:19:39, seen in news:comp.lang.javascript,
cy****@batomic.com posted :
var year = (yy < 1000) ? yy + 1900 : yy;

There is or has been at least one browser for which that fails.

You can, for a while, use var year = 2000 + yy%100.

Has anyone checked getYear() on various browsers for years in the
range 2095-2105?


Not that its relevant, in 100 years or so I doubt people will even know
what getYear was for, or that it will still be broken in that time.

var myDates = new Array();

myDates[0] = new Date(2094, 9, 30, 1, 59).getYear();
myDates[1] = new Date(2095, 9, 30, 1, 59).getYear();
myDates[2] = new Date(2096, 9, 30, 1, 59).getYear();
myDates[3] = new Date(2097, 9, 30, 1, 59).getYear();
myDates[4] = new Date(2098, 9, 30, 1, 59).getYear();
myDates[5] = new Date(2099, 9, 30, 1, 59).getYear();
myDates[6] = new Date(2100, 9, 30, 1, 59).getYear();
myDates[7] = new Date(2101, 9, 30, 1, 59).getYear();
myDates[8] = new Date(2102, 9, 30, 1, 59).getYear();
myDates[9] = new Date(2103, 9, 30, 1, 59).getYear();
myDates[10] = new Date(2104, 9, 30, 1, 59).getYear();
myDates[11] = new Date(2105, 9, 30, 1, 59).getYear();
for (i=0;i<myDates.length;i++){
document.write(myDates[i]+', ')
}
IE6:
2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105

Opera 7, Opera 8, Mozilla Firefox 1.0.4 :
194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #5
JRS: In article <gb********************@comcast.com>, dated Mon, 4 Jul
2005 14:01:47, seen in news:comp.lang.javascript, Randy Webb
<Hi************@aol.com> posted :
Dr John Stockton wrote:
Has anyone checked getYear() on various browsers for years in the
range 2095-2105?


Not that its relevant, in 100 years or so I doubt people will even know
what getYear was for, or that it will still be broken in that time.


For those neddies who only wish to show the current date on their pages,
that is so. But javascript is a general-purpose tool, and might be used
to calculate about any date within its range; we cannot predict why.

For a simple example, the upper limit of the DOS internal date format is
in the year of new Date(1980,0,65535) and those using getYear might
like to know whether it increments steadily from now to then.
... (tests, results) ... Those results show that for all tested browsers getYear()

increments at the 2099 to 2100 transition; but none of those currently
return 5, and I have heard of at least one that would.

Thanks.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.