admin管理员组

文章数量:1318983

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.

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.

Share Improve this question edited Jun 21, 2015 at 20:05 kaaposc 1741 silver badge9 bronze badges asked Jun 21, 2015 at 19:42 jadojado 9549 silver badges21 bronze badges 3
  • 1 What have you already researched? – PM 77-1 Commented Jun 21, 2015 at 19:44
  • possible duplicate of Using custom type attribute in <script> tags such as jQuery's text/x-jquery-tmpl – Boaz Commented Jun 21, 2015 at 19:48
  • When it es to running the code "CoffeeScript is a little language that piles into JavaScript". – PM 77-1 Commented Jun 21, 2015 at 19:48
Add a ment  | 

2 Answers 2

Reset to default 10

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.

http://paperjs/tutorials/getting-started/working-with-paper-js/

These people seem to be doing what you are asking about. I don't know how, but maybe this will get you started.

<!-- Load the Paper.js library -->
<script type="text/javascript" src="js/paper.js"></script>
<!-- Load external PaperScript and associate it with myCanvas -->
<script type="text/paperscript" src="js/myScript.js" canvas="myCanvas">
</script>

本文标签: javascriptHTML make your own ltscript typequottextlanguagequotgtStack Overflow