首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

gecko中的js扩张

2012-11-23 
gecko中的js扩展1 创建js对象对应的idl文件假设要扩展一个hiGecko对象,那么先创建一个idl文件,命名为nsIDO

gecko中的js扩展
1 创建js对象对应的idl文件
假设要扩展一个hiGecko对象,那么先创建一个idl文件,命名为nsIDOMHiGecko.idl,它的内容如下

<!DOCTYPE html><html>  <head>  <meta charset="utf-8">    <meta name="viewport"  http-equiv="pragma">    <title>Cut The Rope</title>  </head>  <body>      <script>           window.self.console.log("************ok************");           window.hiGecko.myval = 34;           window.console.log(window.hiGecko.myval);           window.console.log(window.hiGecko.getIsOK());      </script>  </body></html>

运行webruntime,在终端执行adb logcat | grep -E "^E" 
如果能找到下面一段日志,证明扩展成功

E/GeckoConsole(16685): Content JS LOG at file:///sdcard/index.html:10 in anonymous: ************ok************
E/GeckoConsole(16685): Content JS LOG at file:///sdcard/index.html:12 in anonymous: 34
E/GeckoConsole(16685): Content JS LOG at file:///sdcard/index.html:13 in anonymous: true

热点排行