Javascript 调用函数 需要简单帮助

标签 javascript windows-8

@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/

相关文章:

windows - 如何在 Windows 8 桌面中扫描低功耗蓝牙设备?

javascript - 我正在尝试通过他们的教程设置 Leaflet map ,但有些东西不起作用,任何人都可以看一看并找出原因吗?

python - 硬盘驱动器序列号可以/为什么会更改

javascript - 折线图系列向下钻取到另一个折线图系列

javascript - 无法使用 public 文件夹中的 Meteor 图像

windows-8 - 如何关闭暂停的应用程序的自动终止

windows-8 - 无法从主机ping本地VM

c# - 是否有任何简单的程序可以为 Windows 8 应用程序生成用于 JSON 数据绑定(bind)的类?

javascript - 使用 dataTable 的列过滤不起作用

javascript - 为什么在 while 循环内等待 setInterval Promise 会导致调用量堆积?