Expand my Community achievements bar.

Simple Javascript, difficult placement

Avatar

Level 1

Hi guys,

I have a very simple requirement for which Ive spent the last 3 days trying to figure out.

Requirement:

Show "JAVASCRIPT DISABLED" on form when Javascript is disabled.  Show "" otherwise.

What I've done:

  1. I placed a TextField on MasterPage with default text "JAVASCRIPT DISABLED". 
  2. In event "data::docReady - (JavaScript, client)" wrote a line Page1.StaticText3.rawValue = ""; in order to hide the message.

Problem:

For some reason, this script executes even when Javascript is disabled which completely defeats the purpose of the assignment.. Where should I place this Javascript such that it executes ONLY when Javascript is actually enabled....

Please help! Thanks!

4 Replies

Avatar

Level 10

Hi,

if you want to change the value of a static text use this script.

StaticText.value.text.value = "JS is turned on"

Make sure you restart your Acrobat or Reader when you turned JavaScript on or off, otherwise you don't see any change!

Avatar

Level 10

If you are trying to test for JavaScript without reloading the document it won't work. It has to be done when the document is loaded.

Check this thread for a sample of how to check for JavaScript when opening a document.

http://forums.adobe.com/message/2502422

Essentially you display the message that JavaScript is disabled by default - if JavaScript is turned on then you hide the message and display the form. This is because if JavaScript is disabled you won't be able to run any scripts.

Avatar

Level 1

Guys, thanks for the reply.

Jono - I've tried to follow the steps from your  document 'Javascript and version test.pdf' but the following problem occurs.  My Javscript code runs even when Javascript is disabled! I know this sounds insane, but please look at the snapshots.

Note: For the sake of showing you the problem, I've reversed the visible/hidden.

Initially the TextField is set to Hidden.  Then, in the initialize event - I set it to Visible... 

JSProblem2(2).PNG

As you can see below, even when the bar says "Javascript is currently disabled", it sets the TextField to Visible.

JSProblem.PNG

I've been hacking at this for days now, is there something that I'm missing.  This shouldnt be this difficult, right?

Thanks again for your help.

Avatar

Level 10

Can you share the form via acrobat.com or something like that?

If JavaScript is turned off nothing should happen. The only other thing I can think of off-hand is some sort of corruption.