@TheSystem 这是代码,看看并解决它
<div class="fragment groupeditemspage">
<header aria-label="Header content" role="banner">
<button class="win-backbutton" aria-label="Back" disabled></button>
<h1 class="titlearea win-type-ellipsis">
<span class="pagetitle"><b>OvalFox </b>News Reader</span>
</h1>
</header>
<section aria-label="Main content" role="main">
<progress class="win-ring withText" id="loadingIndicator"></progress>
<div class="groupeditemslist" aria-label="List of groups" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none' }"></div>
</section>
</div>
上面是 html 代码,如果您看到的话,它包含进度标记,当我启动 Windows 8 应用程序时,它会显示进度栏,并且一旦我单击任何项目即可毫无问题地加载内容,进度栏就会保持运行并隐藏查看其详细信息页面,打开没有问题,但是一旦我单击后退按钮,这是哪个功能
navigated: function () {
// Do application specific on-navigated work here
var backButton = this.pageElement.querySelector("header[role=banner] .win-backbutton");
if (backButton) {
backButton.onclick = function () { nav.back(); };
if (nav.canGoBack) {
backButton.removeAttribute("disabled");
} else {
backButton.setAttribute("disabled", "disabled");
}
}
},
即使页面默认加载内容,进度条也会出现在主页中,并且不再隐藏
这是进度条的javascript代码
for (var n = 0; n < items.length; n++) {
var article = {};
// Get the title, author, and date published.
article.title = items[n].querySelector("title").textContent;
article.author = items[n].querySelector("creator").textContent;
article.date = items[n].querySelector("pubDate").textContent;
var thumbs = items[n].querySelectorAll("content");
article.content = items[n].querySelector("description").textContent;
var staticContent = toStaticHTML(items[n].querySelector("description").textContent);
var progressBar = document.getElementById("loadingIndicator").style.display = 'none';
progressBar.value = 1;
// Process the content so that it displays nicely.
if (thumbs.length > 1) {
article.thumbnail = thumbs[thumbs.length - 1].attributes.getNamedItem("url").textContent;
}
else {
var firstindex = article.content.indexOf("<img");
if (firstindex !== 1) {
var secondindex = article.content.indexOf("src=", firstindex) + 5;
var thirdindex = article.content.indexOf("\"", secondindex);
article.thumbnail = article.content.slice(secondindex, thirdindex);
}
}
上面的代码包含以下代码部分
var progressBar = document.getElementById("loadingIndicator").style.display = 'none';
progressBar.value = 1;
上面的代码是实际代码,用于在内容加载后隐藏进度栏,但是一旦单击后退按钮,此功能就不起作用
希望能从@TheSystem 和其他人那里获得关于这个详细而复杂的代码的帮助
最佳答案
此代码不符合您的想法:
var progressBar = document.getElementById("loadingIndicator").style.display = 'none';
progressBar.value = 1;
你想要
var progressBar = document.getElementById("loadingIndicator");
progressBar.style.display = 'none';
progressBar.value = 1;
关于Javascript 调用函数 需要简单帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14915045/