admin管理员组文章数量:1399482
I know that IE could run VBScript and JScript, but I want cross-browser things that use another language than JavaScript, so that I wrote this:
<script src='bla.rb' type='text/ruby'></script>
<script src='bla.coffee' type='text/coffescript'></script>
<script src='bla.ics' type='text/icedcoffescript'></script>
It would run normally. How to make these tags works?
I know that IE could run VBScript and JScript, but I want cross-browser things that use another language than JavaScript, so that I wrote this:
<script src='bla.rb' type='text/ruby'></script>
<script src='bla.coffee' type='text/coffescript'></script>
<script src='bla.ics' type='text/icedcoffescript'></script>
It would run normally. How to make these tags works?
Share Improve this question edited Jan 12, 2013 at 16:32 user142019 asked Jan 12, 2013 at 7:17 KokizzuKokizzu 26.9k40 gold badges149 silver badges256 bronze badges 7- What is your question then? – polin Commented Jan 12, 2013 at 7:18
- 4 I wouldn't be surprised if there were browsers that you could install new languages in, but if you're looking for a cross-browser solution, then no, you're stuck with Javascript. – Mr Lister Commented Jan 12, 2013 at 7:20
- 3 @MrLister you could install a language interpreter through Javascript. Javascript is perfectly capable of parsing Ruby. – John Dvorak Commented Jan 12, 2013 at 7:24
- also see stackoverflow./questions/14180092/… – John Dvorak Commented Jan 12, 2013 at 7:25
- 1 @MrLister I thought coffeescript was piled server-side to javascript? – John Dvorak Commented Jan 12, 2013 at 7:31
4 Answers
Reset to default 3No, you cannot rely on the presence of any of these other languages in the majority of browsers. You can potentially ask a user to instal a new language or plugin, but JavaScript is the only 'universal' client-side scripting language.
Python can be used if you pile CPython to JavaScript using Emscripten. Maybe you can do the same with Ruby.
Besides Emscripten, there are languages that pile to JavaScript, such as CoffeeScript and Fay. You could also write your own VM in JavaScript and write a piler for your favourite language that targets that VM, of course.
In the end, the browser itself can only interpret JavaScript.
Ruby: Maybe? Not sure how far along this project is, but it does exist.
(Iced)CoffeeScript: Yes. But you have to load one additional JavaScript file as the CoffeeScript piler.
There are many languages that can be piled into JavaScript, including C, C++, Python, PHP, and several others.
There are also several implementations of virtual machines for other languages in JavaScript, including DoppioJVM for JVM languages and JSIL for .NET programming languages.
本文标签: htmlCan I use a language other than JavaScript in clientside scriptingStack Overflow
版权声明:本文标题:html - Can I use a language other than JavaScript in client-side scripting? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744115910a2591511.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论