diff --git a/index.php b/index.php index 6ce79fa..780db5e 100644 --- a/index.php +++ b/index.php @@ -1,23 +1,20 @@ image.url); var backgroundDiv = document.getElementById('background'); - if (images.length > 0) { - backgroundDiv.style.backgroundImage = 'url(https://www.bing.com/' + images[0] + ')'; + var baseurl = 'https://www.bing.com/'; + if (images.length > 0) { + backgroundDiv.style.backgroundImage = 'url(' + baseurl + images[0] + ')'; } let index = 0; let currentBackgroundDiv = backgroundDiv; @@ -218,7 +218,7 @@ async function setBackgroundImages() { const nextIndex = (index + 1) % images.length; const nextBackgroundDiv = document.createElement('div'); nextBackgroundDiv.className = 'background next'; - nextBackgroundDiv.style.backgroundImage = 'url(https://www.bing.com/' + images[nextIndex] + ')'; + nextBackgroundDiv.style.backgroundImage = 'url(' + baseurl + images[nextIndex] + ')'; document.body.appendChild(nextBackgroundDiv); nextBackgroundDiv.style.opacity = 0; setTimeout(() => { @@ -228,7 +228,7 @@ async function setBackgroundImages() { document.body.removeChild(currentBackgroundDiv); currentBackgroundDiv = nextBackgroundDiv; index = nextIndex; - if(index>10)index=0;// 只取前十张 + if(index>10)index=0;// 只取前十张 }, 1000); }, 5000); @@ -482,4 +482,4 @@ $(document).ready(function () { }); - \ No newline at end of file +