Re: [問題] 執行javascript
RHINO : JavaScript for Java - http://www.mozilla.org/rhino/
Rhino is an open-source implementation of JavaScript written entirely in
Java. It is typically embedded into Java applications to provide scripting
to end users.
-----------------------------
SpiderMonkey : JavaScript for C - http://www.mozilla.org/js/spidermonkey/
-----------------------------
PHPJS : the PHP/JavaScript interpreter - http://phpjs.berlios.de/
This scripting language interpreter is implemented in PHP and allows to
execute user-supplied JavaScript-lookalike code server-side, without
compromising security because everything runs safely in a sandbox.
-----------------------------
FESI : a Free EcmaScript Interpreter - http://www.lugrin.ch/fesi/index.html
FESI (pronounced like fuzzy) is a full implementation of the first version
of the EcmaScript language.
(seems that it is written in Java)
-----------------------------
Windows Script - http://msdn.microsoft.com/scripting/
Windows Script is a comprehensive scripting infrastructure for the Microsoft
Windows platform. Windows Script provides two script engines, Visual Basic
Scripting Edition and Microsoft JScript®, which can be embedded into Windows
Applications. It also provides an extensive array of supporting technologies
that makes it easier for script users to script Windows applications.
-----------------------------
NOMBAS : JavaScript Anywhere - http://www.nombas.com/us/
-----------------------------
NJS : NJS JavaScript Interpreter - http://www.njs-javascript.org/
NJS is an independent implementation of the JavaScript language developed
by Netscape and standardized by ECMA. It is designed to be re-entrant,
extendible, fast, and programmable.
-----------------------------
其中有一些似乎不是 interpreter,但類似
我用過 NJS,容易編也蠻容易用的
我自己寫的 javascript wiki parser 幾乎沒有改過就可以直接跑了
Windows 似乎可以做這種事:
test.wsf :
<job>
<script language="JScript">
var x=1;
WScript.Echo(x);
</script>
</job>
然後可以在 command line 直接執行。詳情請自己看 windows scripting裡的document.
( http://msdn.microsoft.com/scripting/ )
RHINO 跟 FESI 都是 Java-based 的
RHINO 跟 SpiderMonkey 是用來作 script embedding 的
PHPJS 的網頁上就有範例了,等於用 js 當 server-side script 的語言
NOMBAS 應該也是用來做 script embedding 的
沒有時間一個一個都玩過,不過我想都大同小異
我覺得對你最快的方法大概是用 WSH 的方法
寫個包含你要執行的 script 的 test.wsf,
然後用滑鼠左鍵點他兩下或是在 cmd.exe 打 cscript test.wsf 執行他
不過他吃的是 VBScript 跟"JScript" 不是 javascript,別搞混啦
要注意一旦 javascript 離開了瀏覽器,
window、 document 等 DOM 物件會全部失效(因為既沒有 window 也沒有 HTML dom)
所以要玩這些東西第一件事就是找出這些程式支援什麼樣的物件
比方說 NJS 支援 System.stdout.writeln
WSH 則用 WScript.StdOut.WriteLine
請翻弄各大直譯器的使用手冊
如果你要 IE 以外的程式來跑包含 HTML 的 javascript
但是這些程式又不是瀏覽器的話,那你需要追加一套 HTML parser
※ 引述《qlight (瓦解)》之銘言:
: 請問除了IE之外 有沒有別的agent or 應用程式
: 可以用來跑 javascript
: 急需呀 thanks!!!
--
╭════┬════┬════┬════┬════┬═─╭═╮╮
║████ █▋◢█│████ ███◣│███◣ █▋╯◢║│
║◤██◥│███◤╰╮██ │█◣ █ █◣ ◤│█▋◢█║│
╰╮██╭╯███◣╭╯██ ███◥│█◤ ◣│◥██◤╰╮
│║██║│█▋◥█│████│█◥█◣ ████╰╮██ ●║
╰╰══┴┴════┴════┴════┴════┴╰════╯
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.52
※ 編輯: TKirby 來自: 140.112.30.52 (04/26 17:59)
Web_Design 近期熱門文章
PTT數位生活區 即時熱門文章