使用 Chrome Canary 65 我想使用Chrome代码段来加载网站的多个页面, 每页
window.performance.timing
?page=home&loadTime=200&domcontentloaded=500
)window.location.href = url + queryString
您可以找到我的current code at this gist
这是我的代码,另请参阅my codepen mock
function testPageLoadTimes()
{
// step 1 get [] of urls / href-values done
var linkList = getMainNavigationLinks()
// step 2 get timings done
var timings = getPerformanceTimings();
// step 3 craft query string done
let querystring = getQuerystring(timings);
// for each link / url do the following fail
for (var link of linkList)
{
if(document.readyState === 'complete')
{
// let timings = getPerformanceTimings();
// let querystring = getQuerystring(timings);
// fail
setTimeout(function()
{
window.location.href=link + querystring}
,6000);
}
}
}
我也尝试过递归方法
function testPage(linkList)
{
console.log("link", linkList[0]);
if(document.readyState === 'complete')
{
let timings = getPerformanceTimings();
let querystring = getQuerystring(timings);
let newUrl = linkList[0]+ querystring;
setTimeout(function(){
console.log(newUrl);
console.time();
window.location.href=newUrl;
},2000);
}
linkList.splice(0, 1);
testPage(linkList);
}
var linkList = getMainNavigationLinks();
testPage(linkList);
由于我对承诺缺乏经验,因此我无法使用承诺制作一些东西
function loadPage(url) {
return new Promise((resolve, reject) => {
resolve(console.log("foo resolve"));
reject(console.log("foo reject"));
});
}
如何使用Chrome代码段加载同一页面并在加载后转到下一页?
第4步现在正在使用
let newUrl = window.location.href
+ "?page=" + window.location.pathname
+"&" + querystring;
console.log("newUrl", newUrl);
window.location.href=newUrl;