Add `onclick` attribute directly to Perspective button

I’m using the WebDev and Perspective modules to create a custom page. In this page, I have a Print button, which I want to trigger a function inside my index.html text resource script.

Is it possible to bypass Perspective’s event handlers and add an onclick attribute directly to the button? For example (this is not what I want to do), show an alert on button click with alert('Hello, World!').

It depends. If this button is being rendered by Perspective, then, no - the only way you can attach custom JS behavior is via a custom module that adds its own Perspective components.
If the button is being rendered via webdev and hosted inside an iframe in a Perspective session, then, yes, you could attach your own code to it.

1 Like