我有一个网站,托管了许多内部报告,每周从不同的来源更新,并且每年我们存档年底的版本。因此,服务器上有一个文件夹结构,如下所示:
Department
Current
report1
report2
<etc.>
2013
report1
report2
<etc.>
2012
<etc.>我创建了一个select,为用户提供了选择所需时间段的选项:
<select id="period" onchange="UpdateLinks(this)">
<option value="current" selected>Current</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
</select>实际链接定义为:
<a onclick="EnablePrint();" href="Offshore\Current\NYK_Offshore_Summary.htm"
id="offshoreSales" TARGET="report">Sales</a><br>请注意,该网站是在两个框架-这些项目显示在“菜单”方面和报告显示在“报告”方面,以防止这是相关的。
在UpdateLinks()中,我尝试更新锚中的href以指向适当的文件夹。根据这里的一些条目,这应该是可行的,但它不适合我!
function UpdateLinks(selected) {
var myURL = 'Offshore\\' + selected.value + '\\';
alert('New URL prefix: ' + myURL);
var newURL = myURL + 'NYK_Offshore_Summary.htm';
document.getElementByID('offshoreSales').href = newUrl;
newURL = myURL + 'NYK_Offshore_Assets.htm';
document.getElementByID('offshoreAssets').href = newURL;
}警报()正在发生,我看到了正确的值--例如“当前”或"2013",但是行
document.getElementByID('offshoreSales').href = newUrl;
都不是。我遗漏了什么?
发布于 2014-07-08 16:32:30
错误地输入:
document.getElementByID('offshoreSales').href = newUrl;尝试:
document.getElementById('offshoreSales').href = newUrl;https://stackoverflow.com/questions/24637033
复制相似问题