我正在制作一个Flash画廊网站,我希望页面底部的文字是闪存的下载链接。此文本更改为当前显示的当前闪存的标题。我希望href标签动态更改以匹配正在播放的特定闪存的文件路径,以便用户可以下载它。这是我第一次玩下载链接,更不用说那些随变量动态变化的链接了。所以简而言之,我希望链接更改为链接数组中存在的文件路径。
包含动态链接的起始代码的函数称为DOWNLOAD
HTML
<body>
<div id="titleText">
<h1>Anon Curb</h1>
</div>
<div id="flashmovie">
<object type="application/x-shockwave-flash" data="swfs/welcomeflash.swf">'+
<param name="movie" value="swfs/welcomeflash.swf">
</object>
</div>
<!-- end #container -->
<div id="buttonCon">
<div id="buttons">
<button id="next">next</button>
<button id="rand">Random</button>
<button id="back">Back</button>
</div>
</div>
<div id="titleCon">
<a href="#" id="downLink">
<div id="title">Hit random button</div>
</a>
</div>
<!-- end #wrapper -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
<script src="js/flashcollection.js"></script>
</body>
JAVASCRIPT
$(document).ready(function () {
var links = [
'swfs/#1%20(Special%20Japanese%20Extended%20Dance%20Mix).swf',
'swfs/$D6.swf',
'swfs/(MAD)%20Huh.swf'
];
var displaytext = [
'#1 (Special Japanese Extended Dance Mix)',
'$D6',
'(MAD) Huh'
];
var c = 0
var flashmovie, test, temp;
function init() {
flashmovie = document.getElementById('flashmovie');
document.getElementById('back').onclick = function () {
if (c == 0) {
c = links.length;
}
c--
displayFiles();
}
document.getElementById('next').onclick = function () {
if (c == links.length - 1) {
c = -1;
}
c++;
displayFiles();
}
document.getElementById('rand').onclick = function () {
temp = c;
while (c == temp) {
c = Math.floor(Math.random() * links.length);
}
displayFiles();
}
}
function displayFiles() {
test = links[c].substring(links[c].lastIndexOf('.') + 1, links[c].length);
document.getElementById('title').innerHTML = displaytext[c];
flashmovie.innerHTML =
'<object type="application/x-shockwave-flash" data="' + links[c] + '">' +
'<param name="movie" value="' + links[c] + '">' +
'<\/object>';
}
function download() {
document.getElementById('rand', 'back', 'next').onclick = function () {
document.getElementById('downlink').attr("href", links[c]);
}
}
window.addEventListener ?
window.addEventListener('load', init, false) :
window.attachEvent('onload', init);
});
答案 0 :(得分:2)
正确的javascript
这使用Soltani Neji编辑的下载功能以及标签来更改下载属性,如果没有它,它将无法正常工作。虽然
,但不知道这是正常的还是特殊的var c = 0;
var flashmovie, test, temp;
function init() {
flashmovie = document.getElementById('flashmovie');
document.getElementById('back').onclick = function () {
if (c == 0) {
c = links.length;
}
c--
displayFiles();
download();
}
document.getElementById('next').onclick = function () {
if (c == links.length - 1) {
c = -1;
}
c++;
displayFiles();
download();
}
document.getElementById('rand').onclick = function () {
temp = c;
while (c == temp) {
c = Math.floor(Math.random() * links.length);
}
displayFiles();
download();
}
}
function displayFiles() {
test = links[c].substring(links[c].lastIndexOf('.') + 1, links[c].length);
document.getElementById('title').innerHTML = displaytext[c];
flashmovie.innerHTML =
'<object type="application/x-shockwave-flash" data="' + links[c] + '">' +
'<param name="movie" value="' + links[c] + '">' +
'<\/object>';
}
function download() {
document.getElementById('downLink').setAttribute('href', links[c]);
document.getElementById('downLink').setAttribute('download', displaytext[c]);
}
window.addEventListener ?
window.addEventListener('load', init, false) :
window.attachEvent('onload', init);
});
答案 1 :(得分:1)
大家好,我解决了这个问题,这对我有用 对于HTML文件,您只需要添加第一张图片的href,因为文件在启动时总是加载第一张图片,您还需要将attribut下载添加到标记中,所以这就像
service car functions = foldl (.) id (reverse functions) $ car
对于javascript,您需要像这样编辑下载功能 然后在每个按钮点击事件中调用它,如下所示:
<div id="titleCon">
<a href="unknittingmouse1.swf" id="downLink" download="">
<div id="title">Hit random button</div>
</a>
</div>
希望有所帮助:)