Javascript is put in text/javascript
and Coffeescript also has support for it, but I was wondering it there was a way to make my own? I'd like to make a Golfscript interpreter that anyone can do <script type="text/golfscript">
for and it would be put through the interpreter.
Leaving aside the (usually) unrealistic options of persuading all your users to install a browser extension or custom browser…
The only way you can do this is with a programming language already supported by the browser. In most cases that means JavaScript.
You can access the content of the element through the DOM:
document.querySelector('script[type="text/golfscript"]').textContent
… and then have a parser and interpreter written in JS.
You will probably want to use querySelectorAll
and a loop.
NB: text/golfscript
doesn't appear to be a registered MIME type. You'll probably want to use the x
prefix to mark it as experimental and use application
since it is a programming language: application/x-golfscript
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With