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.
- 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
2 Answers
Reset to default 10Leaving 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
版权声明:本文标题:javascript - HTML make your own <script type="textlanguage">? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742056097a2418302.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论