Steve said:
Yep
In an older version of FF it needed an alert box.
The latest one I installed doesn't need it. ( or doesn't seem to
need it )
Appreciate the feedback though.
It's just something I've been tinkering with.
Steve,
I like to explore what's possible, also - called tinkering, I guess
)
So I tried the code below, which also *seems* to work.
I have a couple of questions
1. Why is testit() defned as
new function testit() ?
Does this give the same result as replacing this line by:
testit()
function testit() ?
2. The var ImageToLoad is defined outside testit() as a local, as I
understand it (local because the prefix var is used).
Is it still known inside testit() or does the declaration there create a new
global variable (global because the prefix var is not used)?
(I note that your code declares it as global, i.e. outside all functions.)
3. How does loadit() know the variables imageToLoad, img and caption ?
Do all internal functions inherit variables from their parent function ?
//========= My function ================
function newWindow(img,caption)
{
var imageToLoad = new Image()
new function testit()
{
imageToLoad.src = img
// we need a little pause while the script gets the image since the
image is on the server,
// or the browser will open the window and write the script before the
image is cached,
// which causes the script to write zeros for the resizeto dimensions.
setTimeout(loadit,1000)
//--- Internal function ---
function loadit()
{
//check to see if we have the dimensions and if not, go back and wait
another 1 second
var w = imageToLoad.width
if (w == 0 )
testit()
else
{
var h = imageToLoad.height
var windh = h + 50
spawnJimcoPopup
('picture.html?picture=' + img + '&caption=' + caption
+ '&height=' + h + '&width=' + w
, '_blank'
,
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no'
, windh,w,'center','0','pixel')
}
} //--- End loadit() ---
}//--- End testit() ---
}