diff --git a/docs/.vuepress/theme/layouts/Layout.vue b/docs/.vuepress/theme/layouts/Layout.vue index dba46e8740..0177866330 100644 --- a/docs/.vuepress/theme/layouts/Layout.vue +++ b/docs/.vuepress/theme/layouts/Layout.vue @@ -13,29 +13,31 @@ import ParentLayout from '@parent-theme/layouts/Layout.vue' import CarbonAds from '@theme/components/CarbonAds.vue' -window.addEventListener('load', () => { - // function called if wwads is blocked - function ABDetected() { - document.getElementsByClassName("wwads-cn")[0].insertAdjacentHTML("beforeend", "
为了本站的长期运营,请将我们的网站加入广告拦截器的白名单,感谢您的支持!万维广告
"); - }; +if (typeof window !== 'undefined') { + window.addEventListener('load', () => { + // function called if wwads is blocked + function ABDetected() { + document.getElementsByClassName("wwads-cn")[0].insertAdjacentHTML("beforeend", "
为了本站的长期运营,请将我们的网站加入广告拦截器的白名单,感谢您的支持!万维广告
"); + }; - //check document ready - function docReady(t) { - "complete" === document.readyState || - "interactive" === document.readyState - ? setTimeout(t, 1) - : document.addEventListener("DOMContentLoaded", t); - } + //check document ready + function docReady(t) { + "complete" === document.readyState || + "interactive" === document.readyState + ? setTimeout(t, 1) + : document.addEventListener("DOMContentLoaded", t); + } - //check if wwads' fire function was blocked after document is ready with 3s timeout (waiting the ad loading) - docReady(function () { - setTimeout(function () { - if( window._AdBlockInit === undefined ){ - ABDetected(); - } - }, 3000); - }); -}) + //check if wwads' fire function was blocked after document is ready with 3s timeout (waiting the ad loading) + docReady(function () { + setTimeout(function () { + if( window._AdBlockInit === undefined ){ + ABDetected(); + } + }, 3000); + }); + }) +} export default { name: 'Layout',