Javascript? Or a simple way to toggle visibility?

Request Type: 
General Assistance
Author: 
Owen Miller
Issue/Request: 

I am creating a website for my research group. On our publications page, I have a list of published papers / references, and I would like to have separate links for each paper that a visitor can click to view the abstract that they’re interested in (without showing all abstracts at all times). I can do this on my current (non-Yale) website with a simple Javascript function:

function toggle(showHideDiv) {
  var ele = document.getElementById(showHideDiv);
  if (ele.style.display == “block”) {
    ele.style.display = “none”;
  }
  else {
    ele.style.display = “block”;
  }
}
 
which is then simply included in the href attribute of the abstract link, with the appropriate element ID.
 
I have two questions:
  (1) Is it possible to include Javascript in the site?
  (2) If not, is there a simple alternative way to create the functionality I’ve mentioned here? I tried testing a collapsiblock a little bit, but it didn’t seem well-suited to create a simple link inline with other content. (Also – I generate the html for the whole publications page offline, which seems to make the collapsiblock option less manageable.)
 
Thanks in advance for any help you can provide.

Hello Owen,

You can add javascript but you’d have to enable the JS Injector module. I’m not sure if it will do what you are trying to accomplish but you can try. I believe you can accomplish that task if you create a view of these publications. The view will give you sorting options you can use.

Josue