javascript syntax question
- Started
- Last post
- 6 Responses
- pkny
i'm writing within my js function the following:
item.onload = someFunction (parameter);
^^ ie, saf, ff all run the code fine
but in ie reports it as incorrect syntax (BUT still runs).. and it should be: item.onload = someFunction; << this forces me to have my parameter variable as a global so it can be read in by "someFunction" ..
my question is what the proper syntax for:
item.onload = someFunction (parameter);without ie giving me hell
thx
- cosmo0
what is "item" variable?
- pkny0
item is a Image object
- cosmo0
could you post a link? I would like to see the whole script.
- neverblink0
I think it's either:
item.onload = someFunction;
or
item.onload = function(parameter){
// function goes here
}- function someFunction(paramet... etcneverblink
- the second option will work - but i want to make my onload function refer to a function outside of that paradigmpkny
- pkny0
http://dev.8-pt.com/test/loader.…
in my load function > item.onload = loadItem < is where the problem... if i do: item.onload loadItem (parameter) << ie gives a problem.. but it still runs.
- neverblink0
var NewImg= Array("image1.jpg","image2.jpg...
var imageDB = Array();function preload(i){
imageDB[i] = document.createElement('img');
imageDB[i].setAttribute('src', NewImg[i]);
imageDB[i].setAttribute('onload... someFunction(i));
}- the "..." should be a " ', "
but QBN changed thatneverblink - thanks for the tippkny
- the "..." should be a " ', "