The interface is only used to obtain the startup parameters passed when opening the offline package. For parameters passed by pushWindow
, please use AlipayJsBridge.startupParams
to obtain.
Use getStartupParams interface
AlipayJSBridge.call('getStartupParams', {
key: ['url','xxx'] // Optional; filter the returned results according to the key value. If it is left empty, the results will be returned completely
}, function(result) {
console.log(result);
});
Code sample
<script>
function ready(callback) {
// Call directly if JSBridge has been injected
if (window.AlipayJSBridge) {
callback && callback();
} else {
// Monitor the injected events if JSBridge hasn't been injected
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function() {
// With key parameter
AlipayJSBridge.call('getStartupParams', {
key: ['url']
}, function(result) {
alert(JSON.stringify(result));
});
// Without key parameter
AlipayJSBridge.call('getStartupParams', function(result) {
alert(JSON.stringify(result));
});
});
</script>
API
getStartupParams
Input parameter
Name | Type | Description | Required | Default value |
---|---|---|---|---|
key | Array | Obtain the value of the corresponding key based on the passed key | N | null |
Output parameters
Return the corresponding startup parameters, such as: {url: 'https://taobao.com', xx: 'Other startup parameter'}
.
- If there are no input parameters, all
startupParams
parameters will be returned. - If there are input parameters, return the corresponding values based on the input parameters.
- If there is no corresponding key value in the startup parameters, the key is not included in the returned values, and no error is reported.
Error code (Number type)
Error code | Description |
---|---|
2 | Parameter exception; key is an empty array or other type. |
12 | Unknown errors |