Q:

Unable to create external link to javascript:void();

While writing a post on menu items without an actual link, I stumbled upon a strange behavior in Joomla 3.3.3:
I wanted to point out that an <a> tag linking to "#" might cause the page to scroll to the top when clicked, and that it might be better to use javascript:void(); in the link field for the External URL menu item. (This article explains why.)
I used to do this myself, but now I discovered that in Joomla 3.3.3, it refuses to save if the link field contains javascript:void();. Take a look at this screenshot (before and after hitting the "Save" button):

I just tested it on an older Joomla version (3.0.3), and I could still use javascript:void(); in the link field.
Is this a bug in newer versions of Joomla, or was it decided that linking to javascript is not allowed anymore, somewhere between J3.0.3 and J.3.3.3?

A:

It was actually a bug that it worked (or to be more specific a security issue). The current behaviour is correct.
References:
Menu item type of External URL can not be saved with javascript:void() 
How to let menu item execute Javascript in Joomla 3.2?

A:

As an addition to Valentin's answer, this is how to add javascript code to a menu item:

Create a custom link menu item
Add  # in the link field
Handle the click event by adding javascript elsewhere on the page (e.g. in the footer).

Example:
jQuery(document).ready(function($){   
  $(".menuitemclass").click(function () {
    //your javascript function;     
  });
});

