How to add a javascript field to custom content type I have a custom content type called 'Visualisation'. I would like a user to be able to upload their own javascript file for each instance of the content type. I would then like to load this script on the page in which the content is displayed.

I have tried adding a custom field 'file', however Drupal doesn't allow javascript files and appends the file with 'txt'. How can I add a javascript file and then load when the content is displayed?

EDIT

As it seems unsafe to achieve this the way I've mentioned above I'll try and elaborate on what I'm trying to do.

The content type is for HTML5 canvas visualisations. Each visualisation will use a custom created script file. The whole content will consist of a title, canvas element, javascript file and description. I therefore need to attach a script to each visualisation.

Would it be better to have a field with just the name of the file and load it in the page template?

Many thanks for any help.
First things first: a warning. 
This sounds like an extremely dangerous idea. If you do this, please at least make sure that you're only opening this up to trusted users (as allowing people to place javascript on your page could lead to some very, very bad things, much like the php filter.)

That being said, if your sure you want to do this, your gonna need to add the js to your page programmaticly. You could easily do this through your theme functions of template_preprocess_node.

Find that function in your template.php file. You'll want to add a condition to check for the content type, then grab the js file and use drupal_add_js to grab the attached js file and attach it to the head.