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
.
http://paperjs.org/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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.