Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Do I really need seven copies of this code?

Participant ,
Nov 06, 2016 Nov 06, 2016

http://v27.ancestry.higgsy.co.uk/

On the above page I have seven buttons.  When you hover over any of them the text changes to white and the user is directed to the appropriate page.  A simple implementation of a rollover image.

You can see the javascript if you use View Page Source and then click the myscript.js link on line 6

Each img has an ID allocated to it which links to the code which, when the button is hovered over, replaces the image with the over image with the white text, then puts the old image back when the hover is out.

But I have found I must customise the code for each button.  Specifically, I have to change the names of the images, variable names and the name of the selector targetting each button.  So I end up with seven copies of the same code!  Can it perhaps be changed to a function which accepts these changes as parameters?

many thanks in anticipation

David

TOPICS
Acrobat SDK and JavaScript , Windows
536
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 06, 2016 Nov 06, 2016

This forum is about JS in PDF files, not web-pages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 08, 2016 Nov 08, 2016

How does JS (assuming you mean javascript) run inside a PDF document?  I've only been aware of using it in my web pages.  If I have really posted this question in the wrong forum can you say which one I should have used? Thanks, David

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016
LATEST

JS is used in many environments, the most known of which is indeed in web-pages, but certainly not the only one.

You can try StackOverflow, for example.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines