Click to See Complete Forum and Search --> : Two rookie questions...


Squire
09-09-2003, 08:10 PM
Hi, I've got a couple of rookie questions for ya... ;)


<html><head>
<script>
var count = 0;
function inccount() {
count++;
if(count==4) {
document.write("Count = " + count);
}
}
</script>
</head><body>
<img src=[etc] onLoad="inccount()" onError="inccount()">
</body></html>

1) When I view this (in IE), I expect count to equal 1 or however many times an event calls inccount(), instead, after a few seconds, I just get "Count = 4" then a ie/c++/runtime error. Is my function looping? How would make it purely event driven?

2) How would I run a local executable (with parameters from a few var's) from js? The only thing I can think of, is to load a small graphic and have an already running program regularly check for its existance. But this wouldn't give me any parameters (or very few at least, if I varie the image source).


Thanks!

Fang
09-10-2003, 02:48 AM
1) document.write is only called when count is 4, so no othe value of count will do anything.
More importantly, once your script has loaded (data stream has stopped)
Any call to document.write will start the data stream again and as a result overwrite your existing document.
Your function no longer exists, hence the error, only the text "Count = 4"

2) Browsers can not interact with executables using Javascript.
The exception being activeX objects which are IE specific.
You could probably do it with VB.