Back button as menu-item (jQuery)



This contribution discribes how to make a "go back to previous page" menu link

Create a new menu link
Use # or route:<nolink> for the link

Use the module Menu Link Attributes to add a class to the menu link

Menulink toevoegen




Use the element inspector of your browser to find the class of the menu link


Class via inspector

In this example we work with the class set with Menu Link Attributes

Paste this jQuery code JS injector or the .js file in your theme.

(function ($) {
  Drupal.behaviors.GaPaginaTerug = {
    attach: function(context, settings) {
      $('.pagina-terug').bind('click', function() {
              return false;

The green marked area is the class to which the jQuery is applies. Change this into the class you are using.

jQuery code

Emty the caches.

Every time you click on the menu link, you will go back one page in het browser history.