我必须做一个小网站,我得到了一个JavaScript,它在控制台返回页面加载时间。 那很好。但是,当我尝试用警报完成同样的事情时,它将无法工作。 我的代码:返回页面加载时间作为警报不起作用
$(window).load(function(){
setTimeout(function(){
window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance ||
{};
var timing = performance.timing || {};
var parseTime = timing.loadEventEnd - timing.responseEnd;
console.log('Ladezeit: ', parseTime, 'ms');
alert('Sorry for the ', parseTime, 'ms, till the website was completely loaded.')
}, 0);
});
的执行console.log工作正常,但警报只显示了“对不起,” 任何人都知道是什么问题?
呀,警报不采取多个参数..你需要连接字符串'“对不起了” +分析时+“毫秒,等等。'' –
哦哇。我完全忘记了:D非常感谢 –