summaryrefslogtreecommitdiff
path: root/doc/api/jsapi.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/jsapi.txt')
-rw-r--r--doc/api/jsapi.txt61
1 files changed, 57 insertions, 4 deletions
diff --git a/doc/api/jsapi.txt b/doc/api/jsapi.txt
index 56bb3edb..debf2a5e 100644
--- a/doc/api/jsapi.txt
+++ b/doc/api/jsapi.txt
@@ -1848,17 +1848,20 @@ Text label of a tab, child of *wv.tabBox*.
[source,javascript]
----
-String wv.inject(String script, [Object argument], [Boolean global])
+String wv.inject([String code|Function code], [Object arg], [Number line], [Boolean global])
----
Injects a script into a webview
::
-_script_;; The script to inject
-_argument_;; If the script isn't injected into the global scope the script is
-wrapped inside a function. +argument+ then is accesible via
+_code_;; The script to inject, either a string or a function. If it is a
+function the body will be wrapped inside a new function.
+_arg_;; If the script isn't injected into the global scope the script is
+wrapped inside a function. +arg+ then is accesible via
+arguments+ in the injected script, optional
+_line_;; Starting line number, useful for debugging. If linenumber is
+greater than 0 error messages will be printed to stderr, optional.
_global_;; +true+ to inject it into the global scope, +false+ to encapsulate it
in a function, optional
_returns_;; The return value of the script. If the script is injected globally
@@ -1866,6 +1869,39 @@ inject always returns +null+. The return value is always converted to a string.
To return objects call JSON.parse on the return value.
****
+====
+.Example
+[source,javascript,src_numbered]
+------
+//!javascript
+
+function injectMe() {
+ var text = arguments[0];
+ document.body.innerHTML = text;
+ text = y;
+ var d = document.createElement("div");
+ document.body.appendChild(d);
+}
+signals.connect("documentLoaded", function(wv) {
+ wv.inject(injectMe, "foo", 4);
+});
+------
+
+The debugging message will be as follows:
+
+[source,txt]
+------
+DWB SCRIPT EXCEPTION: An error occured injecting injectMe.
+DWB SCRIPT EXCEPTION: in line 6: Can't find variable: y
+==> DEBUG [SOURCE]
+ ...
+ 5 > document.body.innerHTML = text;
+--> 6 > text = y;
+ 7 > var d = document.createElement("div");
+ ...
+------
+====
+
****
[float]
==== *history()* ====
@@ -3171,6 +3207,23 @@ an Error, this method will also print the corresponding source of the error.
****
****
+[[generateId]]
+[float]
+==== *generateId()* ====
+
+[source,javascript]
+----
+String script.generateId()
+----
+
+Generates a unique id.
+
+ ::
+
+_returns_;; A unique id.
+****
+
+****
[[getPrivate]]
[float]
==== *getPrivate()* ====