Skip to main content
Participating Frequently
Jan 6, 2017 2:16 AM UTC
Question

Javascript 1.6 stopped working, how to fix this?

I have a PDF form with embedded Javascript that I made a while back. It's been working fine for months, but today it started giving me this error:

TypeError: Item.indexOf is not a function

I looked around the forum and found that this seems to be a problem with older Acrobat not supporting JS 1.6. But I'm using Acrobat 2015, which should support this call. And again, this script had been working fine until today.

I don't know if it's related, but the only factor I can think of is that I've downloaded and used a heavily JSed PDF. That PDF worked just fine, but would it be possible that this PDF somehow disabled my Acrobat's JS 1.6 support?

How do I get JS 1.6 support back?

This topic is closed to new replies. Start a new post to keep the conversation going.

8 replies

Participating Frequently
Jan 6, 2017 11:37 AM UTC

Hmm. Weird. The error just went away as mysteriously as it appeared. Didn't even reboot, reinstall or any of the standard magical fixes.

Thanks for all the help -- hope it doesn't come back again!

Translate
Inspiring
Jan 6, 2017 8:58 PM UTC

Is there any chance that whatever "Item" was set to changed?

Translate
Inspiring
Jan 6, 2017 3:00 AM UTC

What it "Item", exactly? This problem probably isn't related to what you're assuming. If you're using it with something that's supposed to be a string, I'd guess that it's not actually a string in this case. Same idea if it's supposed to be an array, but isn't.

A fairly common example of how this could happen is when you get the value of a text field using the value property. Most of the time it will be a string, but it could also be a number or a boolean. Since a number of boolean doesn't have an indexOf method, you'll get this error. The fix in cases like this is to get the field value as a string using the valueAsString field property.

Translate
Participating Frequently
Jan 6, 2017 3:29 AM UTC

Thanks for the answer, but there doesn't seem to be any problem with the script itself. I tested the exact same PDF on a different machine and it runs just fine. Also runs fine in Adobe Reader on the same machine.

And yes Item is indeed a string.

Translate
Inspiring
Jan 6, 2017 3:53 AM UTC

What happens when you open the interactive JavaScript console by pressing Ctrl + J and enter this line of code:

"ABCD".indexOf("B");

and execute it by pressing Ctrl + Enter

It should return 1.

Translate