Configures the title, subtitle and option menu in title bar.
Note:Due to App Transport Security (ATS), please use https or bases64 for image URL in iOS platform.
AlipayJSBridge.call('setTitle', {
title: 'Title',
});
<h1>Please press the following buttons</h1>
<a href="javascript:void(0)" class="btn title">Configure title only</a>
<a href="javascript:void(0)" class="btn subTitle">Configure title and subtitle</a>
<a href="javascript:void(0)" class="btn clear">Clear title</a>
<script>
function ready(callback) {
// Invoke directly if JSBridge is already injected
if (window.AlipayJSBridge) {
callback && callback();
} else {
// Otherwise listen to `AlipayJSBridgeReady` event
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function(){
document.querySelector('.title').addEventListener('click', function() {
AlipayJSBridge.call('setTitle', {
title: 'Title',
});
});
document.querySelector('.subTitle').addEventListener('click', function() {
AlipayJSBridge.call('setTitle', {
title: 'Title',
subtitle: 'Subtitle',
});
});
document.querySelector('.clear').addEventListener('click', function() {
AlipayJSBridge.call('setTitle', {
title: ' ',
subtitle: ' ',
});
});
});
</script>
AlipayJSBridge.call('setTitle',{
title, subtitle, image
}, fn)
Name | Type | Description | Mandatory | Default |
---|---|---|---|---|
title | string | Text for title | N | |
subtitle | string | Text for subtitle | N | |
image | string | Image URL or Base64 image. title and subtile are not effective if image is set | N |