-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Javascript API
galenlin edited this page Jan 25, 2016
·
4 revisions
-
alert
alert('message');
-
confirm
var b = confirm('message') alert(b);
-
open page
<a href="http://www.wequick.net">wequick</a>
-
close page
window.close();
Small.invoke(method, parameters, callback);
-
alert
Small.invoke('alert', { title: 'title', message: 'message', ok: 'OK' });
-
confirm
Small.invoke('confirm', { title: 'title', message: 'message', buttons: ['OK', 'Cancel'] }, function(i) { alert('Clicked button at index: ' + i); });
-
toast
Small.invoke('toast', { message: 'message', delay: 1 // unit: second, support 1 or 3, default as 1. });
-
hud
Small.invoke('hud', { action: 'show', message: 'message' }); Small.invoke('hud', { action: 'hide', delay: 1 // unit: second, support 1 or 3, default as 1. });
-
Android
Small.registerJsHandler("some_method", new JsHandler() { @Override public void handle(Context context, Map<String, Object> parameters, JsResult result) { Object ret = doSomeStuff(parameters); result.finish(ret); } });
-
iOS
[Small registerJSMethod:@"some_method" withHandler:^(NSDictionary *parameters, JSValue *callback) { id ret = doSomeStuff(parameters); [callback callWithArguments:@[ret]]; }