我想從動態更改的數組中獲取文件路徑並將其存儲在值c中。當我點擊激活它的按鈕時,它會返回Web地址中文件在數組exp中的編號。我想要www.anon-curb.com/swfs/exampleflash.swf,但它給了我www.anon-curb.com/swfs/464; 464是它在陣列中的順序。如何從JavaScript中的數組中獲取文本並將其附加到texarea?
HTML
<div class="share_con">
<button id="share">Get a link!</button>
<textarea id="link"></textarea>
</div>
JAVASCRIPT
var c = sessionStorage.getItem('order');
sessionStorage.setItem('order', c);
var flashcon, test, temp;
share = document.getElementById('share');
link = document.getElementById('link');
function init() {
share.onclick = function() {
console.log('Event: share button clicked');
shareshare();
}
}
function shareshare() {
console.log('Called: shareshare()');
link.innerHTML = 'www.anon-curb.com/' + c;
}
// What displays the actual flash and title for the flash
function displayFiles() {
console.log('Called: displayFiles()');
test = paths[c].substring(paths[c].lastIndexOf('.') + 1, paths[c].length);
document.getElementById('title').innerHTML = displaytext[c];
flashcon.innerHTML =
'<object id="flashcontent" data="' + paths[c] + '">' +
'<param name="movie" type="application/x-shockwave-flash">' +
'</object>';
}
window.addEventListener ?
window.addEventListener('load', init, false) :
window.attachEvent('onload', init);
});
所有變量的創建和正確調用我唯一的問題是我不知道如何獲得包含在數組中,而不是訂單的實際文本它進來了。
你的陣列是可引用的?使用括號符號'arr [c]' –
我給了我更多的JavaScript代碼,我認爲這會有所幫助 – cosmichero2025
你可以給我們一個'sessionStorage'調試嗎? – MayorMonty