初步看了一下,好几处错误
1、curreentTab这个变量打错了。
2、getElementByID应为getElementById
3、getElementById中的参数应该用引号引起来
4、<a href="javascript:onclick="changetab('Tab3','Folder3')"">改为
<a href="#" onclick="changetab('Tab3','Folder3')">我会的也只有这些了。
你先把这几个错误改过来后再慢慢调试吧。
1、curreentTab这个变量打错了。
2、getElementByID应为getElementById
3、getElementById中的参数应该用引号引起来
4、<a href="javascript:onclick="changetab('Tab3','Folder3')"">改为
<a href="#" onclick="changetab('Tab3','Folder3')">我会的也只有这些了。
你先把这几个错误改过来后再慢慢调试吧。
"><a href=javascript:onMouceover="turnon('cell1')">看看效果</a></td>?
应是这样吧?
"><a href=# onmouseover="turnon('cell1')">看看效果</a></td>上面的是点击事件?一样的改法
1、 Function改为function
2、例二中的currentcell.style.backgroundcolor改为currentcell.style.backgroundColor
3、例二中少了一个“{”
qidizi(qidizi)的问题是我写代码的时候出的问题,后来想起了,谢谢你
nonamexz(无名小卒)帮忙,我还是搞不清楚为什么不可以用Function
还有好几个地方你们都说大小写问题,难道JS本身的函数也得区分大小写么?谢谢大家了~
我再去看看
可以查下相应的属性的写法
是不是JS关键字都是小写?
谢谢qidizi(qidizi)再次帮忙~
不是,如你要是用indexof()会出错,因为这不是内定的,只有indexOf()是内定的,
当你不确定关键字拼写时,最好查下资料,或者测试下--呵,
谢谢楼上几位了,那个代码我现在搞清楚了..我把代码贴出来.<html>
<head><title>Tabbed Folders</title>
<style type="text/css">
.tab { background-color: #CCCCCC; }
.tab a { font-family: Verdana, sans-serif; font-size: 11px;
font-weight: bold; position: relative; left: 8px;
top: 4px; color: #663333}
.tab a:visited { color: #663333;}
#Tab1 { background-color: #FFCC99; }.folder { background-color: #CCCCCC; }
.folder p { font-family: Arial, san-serif; font-size: 12px;
margin-top: 10px; margin-right: 25px; margin-bottom: 10px;
margin-left: 20px}
.folder h1 { font-family: Arial, san-serif; font-size: 16px;
margin-top: 20px; margin-right: 20px; margin-bottom: 20px;
margin-left: 20px}
#Folder1 { background-color: #FFCC99; }
</style><script language="JavaScript">
// State variables to keep track of current tab and folder
var currentTab = "Tab1";
var currentFolder = "Folder1";// Function to switch tabs and folders
function turnOn(newTab, newFolder) {
if (currentTab != newTab) {
// Adjust the background colors for the tabs
var thisTab = document.getElementById(newTab);
thisTab.style.backgroundColor = "#FFCC99";
var oldTab = document.getElementById(currentTab);
oldTab.style.backgroundColor = "#CCCCCC"; // Make the new tab the current tab
currentTab = newTab; // Adjust the visibility and background color for the folders
var thisFolder = document.getElementById(newFolder);
thisFolder.style.visibility = "visible";
thisFolder.style.backgroundColor = "#FFCC99";
var oldFolder = document.getElementById(currentFolder);
oldFolder.style.visibility = "hidden"; // Make the new folder the current folder
currentFolder = newFolder;
}
}
</script>
</head><body bgcolor="#FFFFFF" text="#000000"><!-- Create Tabs -->
<div id="Tab1" class="tab"
style="position:absolute; left:20px; top:40px; width:80px;
height:20px; z-index:1;">
<a href="javascript:turnOn('Tab1', 'Folder1');">Inbox</a>
</div>
<div id="Tab2" class="tab"
style="position:absolute; left:100px; top:40px; width:80px;
height:20px; z-index:1">
<a href="javascript:turnOn('Tab2', 'Folder2');">Compose</a>
</div>
<div id="Tab3" class="tab"
style="position:absolute; left:180px; top:40px; width:80px;
height:20px; z-index:1">
<a href="javascript:turnOn('Tab3', 'Folder3');">Addresses</a>
</div><!-- Create Folders -->
<div id="Folder1" class="folder"
style="position:absolute; left:20px; top:60px; width:500px;
height:300px; z-index:1; visibility:visible; overflow:auto">
<h1>Inbox</h1>
<p>Your inbox contains 20 new messages...</p>
</div>
<div id="Folder2" class="folder"
style="position:absolute; left:20px; top:60px; width:500px;
height:300px; z-index:2; visibility:hidden; overflow:auto">
<h1>Compose</h1>
<p>Please enter your message here...</p>
<form>
<p>To: <input type="text">
<p>Subject: <input type="text">
<p><textarea rows="10" cols="40"></textarea>
</form>
</div>
<div id="Folder3" class="folder"
style="position:absolute; left:20px; top:60px; width:500px;
height:300px; z-index:3; visibility:hidden; overflow:auto">
<h1>Address Book</h1>
<p>Select an address...</p>
</div>
</body>
</html>