This API retrieves the startup parameters passed when an offline package is opened. To retrieve parameters passed by pushWindow, use AlipayJsBridge.startupParams instead.
Use the getStartupParams API
AlipayJSBridge.call('getStartupParams', {
key: ['url', 'xxx'] // Optional. Filters the results by key. If omitted, all parameters are returned.
}, function(result) {
console.log(result);
});
Code example
<script>
function ready(callback) {
// If jsbridge is already injected, call it directly.
if (window.AlipayJSBridge) {
callback && callback();
} else {
// If not, listen for the injection event.
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function() {
// With the key parameter
AlipayJSBridge.call('getStartupParams', {
key: ['url']
}, function(result) {
alert(JSON.stringify(result));
});
// Without parameters
AlipayJSBridge.call('getStartupParams', function(result) {
alert(JSON.stringify(result));
});
});
</script>
API reference
getStartupParams
Input parameters
|
Property |
Type |
Description |
Required |
Default value |
|
key |
Array |
Filters the returned results by the specified keys. |
N |
null |
Output parameters
Returns the startup parameters. For example: {url: 'https://taobao.com', xx: 'Other startup parameters'}.
-
If no key is specified, all
startupParamsparameters are returned. -
If a key is specified, only the matching values are returned.
-
If the startup parameters do not contain the specified key, that key is omitted from the response without raising an error.
Error codes
|
Error code |
Description |
|
2 |
Invalid parameter. The key is an empty array or has an invalid type. |
|
12 |
Unknown error. |
该文章对您有帮助吗?