安卓下,用document.title能夠很好地設置app中頁面的title值,可是ios下沒有效果,因此如下這段代碼主要是解決ios下設置title的問題javascript
var userAgent = navigator.userAgent; var cookiestr = document.cookie; if (userAgent.indexOf('cdvsupport') >= 0 || cookiestr.indexOf('cdvsupport') >= 0) { //alert('nativejs') document.write("<script type='text/javascript' src='nacodovafile/js/cdplugins.js#nacodovafile'><\/script>"); document.write("<script type='text/javascript' src='nacodovafile/js/cordova.js#nacodovafile'><\/script>"); } function deviceReadyOne(cb_back){ var deviceReady = function(){ document.removeEventListener("deviceready", deviceReady, false); if('function' == typeof cb_back){ cb_back(); } } document.addEventListener("deviceready", deviceReady, false); } // export default { function setPageTitle(title) { document.title = title; var callback = function(){ try{ window.CD58UtilsPlugin.setTitle(title); }catch(e){} } if (window.CD58UtilsPlugin) { callback(); } else { deviceReadyOne(callback); } }