Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Can we please add an onclick attribute to this module?
Comment | File | Size | Author |
---|---|---|---|
#11 | onclick-1923740-3.patch | 3.27 KB | jpoika |
#8 | onclick-1923740-2.patch | 3.2 KB | jpoika |
#1 | onclick-1923740-1.patch | 2.79 KB | albertski |
Comments
Comment #1
albertski CreditAttribution: albertski commentedHere is a patch that implements this:
Comment #2
Mołot CreditAttribution: Mołot commentedWorks for me and mines.
Comment #3
StephanieFuda CreditAttribution: StephanieFuda commentedThis patch does works for me, I've got an issues with my onclick quotes getting encoded (javascript based click tracking), but this may not be the patch - I'mnot sure yet.
Thanks!
Comment #5
Diane Bryan CreditAttribution: Diane Bryan commentedVery interested to see this fixed! I'll ask our Tom to look into it.
Comment #6
joelpittetConsidering adding this feature if it was disabled by default, and maybe add a tests for the encoding that @Stephanie_42 mentioned in #3
Would turning it off by default, and then just allowing people to enable it through the menu settings work for you?
admin/structure/menu/settings
@Stephanie_42 is it the double quote or single quote encoding that is not working? I would assume that double quotes would be encoded because you'd break the attribute. Also a bit concerned for security here... but discuss that later unless some one can speak to that?
Comment #7
limonazzo CreditAttribution: limonazzo commented4 drupal 6 i use Menu attributes and modify:
menu_attributes.admin.inc
and
on menu_attributes.module.
Comment #8
jpoika CreditAttribution: jpoika commentedI have made the changes to the rc3 version of menu_attributes. Can this be part of the standard?
Comment #10
joelpittetI'm not sure we want to do this but you can add this with
hook_menu_attribute_info()
in your own custom module quite simply.Comment #11
jpoika CreditAttribution: jpoika commentedCorrected the error, in case you change your mind.
Comment #12
joelpittet@jpoika maybe you could create a new module called "menu_attributes_events" and add all the JS event attribute handlers. onmouseover,onblur, etc?
Comment #13
malcomio CreditAttribution: malcomio commentedYes I think it's better to keep event handling out of this module and create a separate module for people who would want that.
For me, Javascript code belongs in a module or a theme so it can be under version control, and allowing code to be added via the CMS is an extra attack vector.
This module allows adding an id to a link, so it's very straightforward to target any menu link.