简体   繁体   中英

Invalid argument in IE

I love IE :)

OK, so I've downloaded a scrip called TinySlidshow ( http://www.leigeber.com/2008/12/javascript-slideshow/ ) works perfectly in FF then I tried IE and boom got an invalid argument error on like 160.

Here is line 160 compressed which is what it looks like by default.

if(oh==h){clearInterval(e.si)}else{if(oh!=h){e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}}

I broke it up so I could find exactly what it was and it came down to this line:

e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'

The line above is quite a few adding/dividing and multiplying on one line so I broke that up so my ocde looked a little like this:

e.style.height = new_hight + 'px'

But it still gave me the error on the line above. I tried putting a semi-colon on the end and it didn't work either...

The script is located here at the moment:

http://www.romarkdesign.com.au/portfolio2.html

Any ideas what I need to change to make IE work?

Same prob here. After watching it go through the debugger a few times, I noticed the pattern of the height being set to '-1px' whenever the error popped up.

I may have fixed it...but it is IE and prone to flying off the handle in spite of my good intentions.

You need to add "if(oh<2){oh=2};" after the opening bracket of the if(oh!=h) statement.

Change:

    if(oh==h){clearInterval(e.si)}else{if(oh!=h){e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}}

to:

    if(oh==h){clearInterval(e.si)}else{if(oh!=h){if(oh<2){oh=2};e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}}

The theory here is that TINY doesn't like negative 'px' values, so I set oh to 2 if it is less than 2 coming into the problem statement. This forces the statement to evaluate to 1 at it's lowest value. '1px' seems to make TINY happy in IE...so far.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM