【发布时间】:2010-10-26 05:12:21
【问题描述】:
我正在尝试设计一个文件托管网站模板,问题是我重新设计了 div 元素的单选按钮,以使用自定义图像而不是使用 javascript 的默认圆圈,
This is image 1 when default page loads
<script type="text/javascript">
<!--
//script to change background-color of the selected
//button and put the appropriate value in an input object
function btnClick(btnNum){
for (i=1;i<=4;i++){
tempBtnVal=document.getElementById('btnVal')
tempBtn=document.getElementById('btn'+i)
tempBtn.style.backgroundPosition=(i==btnNum?'0 -163px':'0 -30px')
tempBtn.style.color=(i==btnNum?'#333':'#6a7072')
}
tempBtnVal.value=btnNum
}
//-->
</script>
我的html
<div id="btn1" name="btn1" class="buttonDiv" value='1' onclick="btnClick('1')" style="background: url(images/inSprite.png) no-repeat scroll 0 -163px; color:#333;"><div id="btnTxt">local</div></div>
<div id="btn2" name="btn2" class="buttonDiv" value='2' onclick="btnClick('2')"><div class="btnTxt">remote</div></div>
如果我点击任何其他选项卡,它工作正常并且该选项卡被选中
Image 2 when clicked on URL Upload
但是脚本存储了最后选择的选项卡的 cookie,所以下次有人访问该站点时会自动显示该选项卡,因为我在 div 中手动硬编码了 css,它破坏了设计,如下图所示选择“URL上传”,然后重新加载页面
Image 3 when exited the browser and revisited the site
在选择器中显示表单上传,但 URL 上传选项卡已打开。
请帮我解决问题,以便如果 URL 上传打开,它会显示上面选项卡中选择的 URL 上传。
由于限制,我不能使用任何框架,我只能使用 javascript 而不能使用框架。请帮我解决,因为我对javascript的了解很少。
非常感谢。
问候,
Shishant Todi
【问题讨论】:
标签: javascript html css