All Products
Search
Document Center

Get startup parameters

Last Updated: Feb 18, 2021

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

  1. AlipayJSBridge.call('getStartupParams', {
  2. key: ['url','xxx'] // Optional; filter the returned results according to the key value. If it is left empty, the results will be returned completely
  3. }, function(result) {
  4. console.log(result);
  5. });

Code sample

  1. <script>
  2. function ready(callback) {
  3. // Call directly if JSBridge has been injected
  4. if (window.AlipayJSBridge) {
  5. callback && callback();
  6. } else {
  7. // Monitor the injected events if JSBridge hasn't been injected
  8. document.addEventListener('AlipayJSBridgeReady', callback, false);
  9. }
  10. }
  11. ready(function() {
  12. // With key parameter
  13. AlipayJSBridge.call('getStartupParams', {
  14. key: ['url']
  15. }, function(result) {
  16. alert(JSON.stringify(result));
  17. });
  18. // Without key parameter
  19. AlipayJSBridge.call('getStartupParams', function(result) {
  20. alert(JSON.stringify(result));
  21. });
  22. });
  23. </script>

API

  1. 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