I have a website that was set up using Webforms with page breaks. So on the same URL, there are multiple "pages" and div blocks on each page, with a progress bar on top so you know what "page" you're on.

I want to repeat JavaScript code so I was thinking of using modules and/or blocks.

Can I call the specific block or code from inside the div?

For example if I make a block with js code, right now it is showing up on every "page" since they all use the same URL, when I only want it some specific places.

I would love if I could use something similar to <script src="sites/all/libraries/myfile.js"> inside an HTML markup div but I'm pretty sure this is not allowed.

  • What are you trying to do? What is your end goal/use case?
    – Jaypan
    Commented Mar 24, 2023 at 22:40
  • drupal.org/docs/7/api/javascript-api/….
    – taggartJ
    Commented Mar 27, 2023 at 3:43
  • @Jaypan The website was created by someone else and the way they set it up was with a bunch of markups on a webform. They copied and pasted the same html/js code thousands of times with just one variable changed. Now that I want to update the js code, I'm looking for a better way to separate the js and the html so we can keep the website the same and just change the js code. I hope that makes sense!
    – Rachel C
    Commented Mar 28, 2023 at 16:02
  • @taggartJ, I've tried this but I cannot figure out how to add it to a specific part of my markup instead of every "page" with the same url since it uses themes/modules
    – Rachel C
    Commented Mar 28, 2023 at 16:03


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.