按随机播放按钮时打开随机 .html 文件

问题描述 投票:0回答:1

我的问题是我已经实现了java脚本随机播放按钮,但只在特定的url中工作,我将其放入行document.location.href我在这个例子中使用了somefile.html。

    jQuery('body').on('click', '#shuffle-button', function() {
        gtag('event', 'Shuffle', {
            'click': 'true'
        });
        ga('send', 'event', 'Shuffle', 'click', 'true');
        document.location.href = '**/somefile.html**';
    }).on('click', '#station-share-toggle, #station-share-close', function() {
        $('#station-share-buttons').toggle();
    }).on('click', '.jp-share-button', function() {
        window.open($(this).attr('href'), "share", "width=500, height=500");
        return false;
    });

因此,在somefile.html所在的同一文件夹中,有 350 多个其他 .html 文件,我希望在单击“随机播放”按钮时将其传输到这 350 多个 .html 文件中的随机文件。 此示例仅适用于 somefile.html。我必须做什么或者我的错误在哪里,如果有人可以选择让它发挥作用,我会很高兴。

javascript html button shuffle
1个回答
0
投票

此示例仅适用于 somefile.html。

您必须引用相同的脚本并在 N 个 HTML 文件中包含相同的 HTML。

从技术上讲,文件夹中的所有文件都可以写入

navigator.strorage
一次,然后用户不必多次请求文件 - 直到他们清除该来源的浏览数据。

然后您可以从

navigator.storage.getDirectory()
获取文件,然后在
iframe
或单独的
window
中渲染,以避免
location.href
,尽管这也可以。

© www.soinside.com 2019 - 2024. All rights reserved.