如何从HTML页面访问Gnome应用程序JavaScript函数?
How can i access to a Gnome application JavaScript function from a HTML page?
我学习了如何将HTML页面嵌入到gnome JavaScript应用程序中,并在Gtk+框架中显示它。
// Create a webview to show the web app
this._webView = new Webkit.WebView ();
// Put the web app into the webview
this._webView.load_uri (GLib.filename_to_uri (GLib.get_current_dir() +
"/hellognome.html", null));
// Put the webview into the window
this._window.add (this._webView);
// Show the window and all child widgets
this._window.show_all();
现在我要访问Gtk+ API(如访问文件系统)或JavaScript函数在我的gnome JavaScript应用程序从这个HTML (hellognome.html)文件使用JavaScript?
像这样:
<html>
<head>
<title>Hello, GNOME!</title>
<!-- Use JavaScript to show a greeting when someone clicks the button -->
<script type="application/javascript">
function greeting () {
document.getElementById ("greeting").innerHTML = ("O hai!");
//// access to a Gtk+ API (like accessing to file system )
or a JavaScript function in my gnome JavaScript application.
}
</script>
</head>
<body>
<br /> <br />
<button type="button" onclick="greeting()">Hello, GNOME!</button>
<!-- Empty H1 element gets filled in when the button is clicked -->
<h1 id="greeting"></h1>
</body>
</html>
你不能在HTML中的JS中使用GTK api。您必须在两者之间建立某种通信方法。例如,连接window-object-cleared
信号,在窗口对象上设置一些方法。
相关文章:
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- Emberjs应用程序加载在除Index之外的所有路由上
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 在AngularJS应用程序中使用封装指令和路由的推荐方式是什么
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- angular 1.5应用程序中的导航栏
- 在Web应用程序中使用Highcharts javascript
- angularjs+rails应用程序中未显示模板
- 使用acess代币登录Facebook,并通过网络应用程序离线发布
- 从HTTPGET返回一个自定义对象列表,以便在Angular 2应用程序中使用
- 科尔多瓦页面类应用程序中的多个谷歌地图
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- Angularjs-utils高亮过滤器在搜索时破坏应用程序
- 在phonegap应用程序内部重定向不起作用
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- MockJax没有在JavaScript应用程序中发送对我AJAX请求的响应
- Node.js正在更改应用程序以使用集群模块
- 在openshift node js应用程序中获取请求
- 如何从HTML页面访问Gnome应用程序JavaScript函数?
- 如何使用C库在JavaScript中创建GNOME应用程序