This interface is used to set the color of TitleBar.
Use setTitleColor interface
AlipayJSBridge.call("setTitleColor", {
color: 16775138,
reset: false // (Optional, false by default) Whether or not to reset the title color to the default one.
});
Code sample
<div style="padding-top:80px;">
<a href="javascript:void(0)" class="btn title">Set the title bar color</a>
<a href="javascript:void(0)" class="btn reset">Reset the title bar color</a>
<a href="javascript:void(0)" class="btn pushWindow">Open a new window with the transparent title bar</a>
<a href="javascript:void(0)" class="btn resetTransparent">Reset to the transparent title bar</a>
</div>
<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(){
document.querySelector('.title').addEventListener('click', function() {
AlipayJSBridge.call("setTitleColor", {
color: parseInt('108ee9', 16),
reset: false // (Optional, false by default) Whether or not to reset the title color to the default one.
});
});
document.querySelector('.reset').addEventListener('click', function() {
AlipayJSBridge.call("setTitleColor",{
color: 16775138,
reset: true
});
});
document.querySelector('.pushWindow').addEventListener('click', function() {
AlipayJSBridge.call("pushWindow", {
url: location.pathname + '?__webview_options__=transparentTitle%3Dalways'
});
});
document.querySelector('.resetTransparent').addEventListener('click', function() {
AlipayJSBridge.call("setTitleColor", {
color: 16775138,
resetTransparent: true
});
});
});
</script>
API
AlipayJSBridge.call('setTitleColor', {
color: 16775138,
reset: false,
resetTransparent: false
}, fn)
Input parameters
Name | Type | Description | Required | Default value | Version |
---|---|---|---|---|---|
color | int | Color value, decimal | Y | - | - |