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
 |  Show 2 more ments

4 Answers 4

Reset to default 3

No, 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