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.
The link that toggles a textarea from plain to rich text uses an anchor tag with javascript in the href property. In some cases this could cause the browser to execute the javascript twice or more and is generally considered bad form. Instead javascript should be executed in the onclick property and href should point to a valid url (or "javascript:void(0);").
This patch changes the toggle link from
<a href="javascript:Drupal.ckeditorToggle('edit-body','Switch to plain text editor','Switch to rich text editor',1);">Switch to plain text editor</a>
to
<a href="javascript:void(0);" onclick="javascript:Drupal.ckeditorToggle('edit-body','Switch to plain text editor','Switch to rich text editor',1);">Switch to plain text editor</a>
Comment | File | Size | Author |
---|---|---|---|
javascript-toggle.patch | 1.37 KB | draenen | |
Comments
Comment #1
dczepierga CreditAttribution: dczepierga commentedI commit it to GIT. Really thx for patch.
Please check the latest dev release and let me know if you notice any poblems with it. Remember to clear Drupal cache and browsers cache before testing.
I also port this patch to D7 - #1095954: [D7] Prevent to call Toggle rich text link href="javascipt:..." multiple times
Greetings