Experiencing an allow java script error message

I am experiencing an error message whenever I try to incorporate Java in one of my tiddlers. The message states that an ‘allow-scripts’ permission is not set. Is anyone familiar with the error and/or know where I can set the needed permissions? Any help is appreciated!

Although TiddlyWiki is a JavaScript application, it does not allow you to run arbitrary JavaScript. Any code stored in the body of tiddlers is simply disallowed.

There are Tiddlywiki techniques to do most of what you would do with JS. Some are easier than their JS counterparts and some are more difficult. If you explain what you were trying to accomplish, we may be able to help.

I am currently building a personal wiki for a show I plan to expound on as an animation project. The code I am trying to implement is for a title sequence I found online. When I open the code through sources in a new tab it runs smoothly.

This led me to believe the issue existed within a permission that needs to be set on TiddlyWiki. However, you seem to be implying the issue runs deeper and requires re-coding with TiddlyWiki-specific techniques. If that’s the case I may need to abandon this specific code block. Since I didn’t write the original code myself, I’m not sure I’d be able to make extensive edits with my current knowledge of Java.

Yes, but they are not all that hard. The trick is that you cannot just throw your code in a <script> tag and assume it will run. There is more to do. There are many ways to go about this. Here’s a simple one to create a JS macro.

The following contains two tiddlers:

currency.json (1.0 KB)

Download it, drag the resulting file to a wiki. Because this does involve JS code, you will have to save and reload it before seeing the effects.

Currency Demo looks like this:

* JPY: <<currency "12345.6789" "JPY">>
* USD: <<currency "12345.6789" "USD">>
* GBP: <<currency "12345.6789" "GBP">>
* EUR: <<currency "12345.6789" "EUR">>
* INR: <<currency "12345.6789" "INR">>

The output looks like this:

  • JPY: ¥12,346
  • USD: $12,345.68
  • GBP: £12,345.68
  • EUR: €12,345.68
  • INR: ₹12,345.68

This works because in the other tiddler, $:/_/my/core/modules/macros/currency.js, we defined the JavaScript macro currency,

/*\
title: $:/_/my/core/modules/macros/currency.js
type: application/javascript
module-type: macro

Macro to return a currency-formatted string for a given currency

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

exports.name = "currency";

exports.params = [
	{name: "amount"},
    {name: "currency"}
];

exports.run = function(amount, currency) {
	return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount)
};

})();

Note that this has field module-type set to macro

We construct an IIFE that creates a name, parameter list, and function on its global exports object. This will be loaded on startup to associate the name currency with the function, using the parameter names.

You can have anything else you need included in that closure, including large third-party JS code.

So that’s one way to work with JS. You can also create widgets, functions, and procedures. You can wrap a number of such tiddlers into a single plugin.

So you definitely can use JS. But you can’t just add it to tiddlers and expect it to work.