使用JavaScript在HTML DOM中设置全屏、隐藏滚动条

不显示滚动条 document.body.style.overflow = "hidden" //不显示滚动条 全屏 document.body.style.height = win.window.innerHeight + "px" document.body.style.width = win.window.innerWidth + "px"

December 31, 2019 · 1 min · holdsky

学习笔记:使用Android V8 (J2V8)JavaScript引擎

集成 在Android Studio的Android工程中,需要在build.gradle文件内容里添加依赖指令,然后gradle构建就会自动化集成J2V8引擎 dependencies { implementation 'com.eclipsesource.j2v8:j2v8:5.0.103@aar' } J2V8的最新版本,可以在marven仓库中查看 https://mvnrepository.com/artifact/com.eclipsesource.j2v8/j2v8 使用示例 示例摘自https://eclipsesource.com/blogs/tutorials/getting-started-with-j2v8/ import com.eclipsesource.v8.V8; public static void main(String[] args) { V8 runtime = V8.createV8Runtime(); int result = runtime.executeIntegerScript("" + "var hello = 'hello, ';\n" + "var world = 'world!';\n" + "hello.concat(world).length;\n"); System.out.println(result); runtime.release(); } 访问JavaScript对象(Object) 假设有这样一段JS脚本 var jsobj = {}; jsobj.hello = "world"; 在J2V8中可以直接访问jsobj对象 import com.eclipsesource.v8.V8; public static void main(String[] args) { V8 runtime = V8.createV8Runtime(); runtime.executeVoidScript("" + "var jsobj = {};\n" + "jsobj.hello = 'world';\n"); // 访问jsobj的属性 V8Object jsobj = runtime.getObject("jsobj"); System.out.println(jsobj.getString("hello")); jsobj.release(); runtime.release(); } 需要注意, V8Object 需要自己手动释放 ...

November 28, 2019 · 1 min · holdsky