Skip to main content
Adobe Employee
March 3, 2025
Question

Interactive PDF buttons in browsers

  • March 3, 2025
  • 2 replies
  • 450 views

Hello,
I created an interactive PDF, which consists of a main page, where you can click 4 buttons. Each one displays a different image and hides the other buttons when an image is shown. I used a straightforward java script code:

var img = this.getField("Winter_IMG");
if (img.display == display.hidden) {
    img.display = display.visible;
} else {
    img.display = display.hidden;
}

var button = this.getField("Spring");
if (button.display == display.hidden) {
    button.display = display.visible;
} else {
    button.display = display.hidden;
}

var button = this.getField("Autumn");
if (button.display == display.hidden) {
    button.display = display.visible;
} else {
    button.display = display.hidden;
}

var button = this.getField("Summer");
if (button.display == display.hidden) {
    button.display = display.visible;
} else {
    button.display = display.hidden;
}

var img = this.getField("overlay_af_image");
if (img.display == display.hidden) {
    img.display = display.visible;
} else {
    img.display = display.hidden;
}







 It works as expected, however when I run it in browsers there are some issues. Google chrome seems reliable, although the buttons remain pressed when I click on them to close the image. I need to click somewhere else on the background to make them "get unstuck". Firefox seems not to pop up the images whatsover. When I run it in Edge, the images are showing up, but when I click again on the buttons to hide them - nothing happens. The buttons and the images are defined as fields i.e. buttons. Is there any way to make it functional in browsers? I'd like to share the file on my blog, so ideally it should be compatible with browsers. Can you give me some guidance on workarounds I can use?

Thanks in advance

2 replies

JR Boulay
Community Expert
Community Expert
March 5, 2025

You can embed the form in a PDF-Portfolio to be sure that it will not be used with a low end PDF reader:

https://helpx.adobe.com/acrobat/using/create-customize-pdf-portfolios.html

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
March 4, 2025

Most 3rd party PDF viewers are unfortunately non-compliant, i.e., they do not implement interactive PDF features correctly. There is nothing you can do except to prevent the PDF from being used in a non-compliant viewer. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Adobe Employee
March 5, 2025

Thanks for the response!

I also assumed the same scenario and thought I already exhausted my ideas. I guess I'll just put a note saying the file is compatible with Adobe and create another non-interactive one that people can run in browsers