<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> 无标题文档 </title>
<script language="javascript">
function showDiv()
{
document.getElementById("divOne").style.display="";
document.all("dateText").value=document.getElementById("divOne").title;
alert(document.all("dateText").value);
var num2=document.all("dateText").value.toLowerCase();
if(num2 == document.getElementById("divOne").title) //這邊的漢字編碼轉換應該有問題
{
alert("字符串相等"+'ok');
}
}
</script>
</head> <body>
<div id="divOne" style="display:none" title="年度目标值采集">
<input type="button" name="btn" value=" <"/>
</div>
<input id ="xxxx" type="text" name="dateText" onclick="showDiv();"/>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> 无标题文档 </title>
<script language="javascript">
function showDiv()
{
document.getElementById("divOne").style.display="";
document.all("dateText").value=document.getElementById("divOne").title;
alert(document.all("dateText").value);
var num2=document.all("dateText").value.toLowerCase();
if(num2 == document.getElementById("divOne").title) //這邊的漢字編碼轉換應該有問題
{
alert("字符串相等"+'ok');
}
}
</script>
</head> <body>
<div id="divOne" style="display:none" title="年度目标值采集">
<input type="button" name="btn" value=" <"/>
</div>
<input id ="xxxx" type="text" name="dateText" onclick="showDiv();"/>
</body>
</html>
解决方案 »
- raphaeljs
- 急~~~~~
- 请教学习方法
- 你们的IE也会非法操作吗:JavaScript正则表达式执行崩溃
- firefox下js处理xpath问题,非常奇怪,高手出招啊
- 如何用JAVASCRIPT遍历一个目录下的文件
- 如果用JAVAscript给表单里面的select追加值!在线等!(菜鸟)
- 点击一链接弹出“Y”or“N”对话框,如选“Y”则进入到新的URL,但这个URL中的参数是从数库中调用出来的,如何正确的传递给URL!!
- 50分的一个正则问题
- 如何在javascript中得到单选框的值
- <frameset > 打印问题,寻求一个好的方法把frameset 边框去年掉。
- String.fromCharCode(event.keyCode)中.为什么不能转换?
1.{}不匹配
2.年度目标值采集==年度目标值数据采集
如果这种情况下都能运行alert("字符串相等"+ok);
我建议把你的电脑砸了。
<script language="javascript" charset="utf-8">
function showDiv()
{
document.getElementById("divOne").style.display="";
document.all("dateText").value=document.getElementById("divOne").title;
alert(document.all("dateText").value);
var num2=document.all("dateText").value.toLowerCase();
if(num2 == '年度目标值采集')
{
alert("字符串相等"+'ok');
}
}
</script>
加上charset="utf-8"
TNT_1st_excellence 就知道我的意思
加上 <script language="javascript" charset="utf-8"> 也就可以了.
<HEAD>
<SCRIPT language="javascript"
src="tabPage.js"></SCRIPT>
</HEAD> <BODY>
<script language='javascript' charset='utf-8'>
var tab=new TabPage('firstTab','tab','tabPageContainer');
var arrayDiv=document.all;for(i=0;i<arrayDiv.length;i++){
var dId=arrayDiv[i].id.toString();
var dTitle=arrayDiv[i].title.toString();
alert("dTitle="+dTitle);
if(dTitle=='年度目标值数据采集'){
tab.addPage(dId,dTitle);
}
}
document.write(tab);
</script> <DIV id="tabPageContainer">
<DIV id="div1" align="center" title="采集模板生成" style="display=none">
<TABLE width="80%" height="80%" bordercolor="#9966CC"
style="border:1px solid #9966CC">
<TR>
<TH scope="col">
asdasasdd
</TH>
<TH scope="col">
asdasd
</TH>
<TH scope="col">
asdasd
</TH>
<TH scope="col">
asdasdasdas
</TH>
</TR>
<TR>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
</TR>
<TR>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
</TR>
<TR>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
</TR>
</TABLE>
</DIV>
<DIV id="div2" align="center" valign="middle" title="年度目标值数据采集" style="display=none">
<FORM>
<INPUT type="text" value="welcome to tabpage!" id="page2_in"
style="border:1px solid black">
<INPUT type="button" value="clickMe"
style="border:1px solid black; background-color:white">
</FORM>
</DIV>
<DIV id="div3" align="center" title="每月完成值数据采集" style="display=none">
<IMG src="/WebRootElec/image/es/tab/27.jpg" width="300" height="300">
<input type="button" name="btn" value="提交" onClick="" />
</DIV>
</DIV>
<SCRIPT language="javascript">
tab.completed();
</SCRIPT>
</BODY>
</HTML>
怎么这里还是不行????
/****************************************************************************************
* tabPage.js
* author 刘肖冲 2004.04.07
****************************************************************************************///tabpage样式
var tabPageFaceConfig =
{
normalLeft : "url(images/tab_a.gif)",
normalMiddle : "url(images/tab_a1.gif)",
normalRight : "url(images/tab_a2.gif)",
pressLeft : "url(images/tab_b.gif)",
pressMiddle : "url(images/tab_b1.gif)",
pressRight : "url(images/tab_b2.gif)",
//左边图片大小
imageLeftWidth : "19px",
imageLeftHeight : "20px",
//右边图片大小
imageRightWidth : "8px",
imageRightHeight : "20px",
//每个tab页的宽度
pageWidth : "150px",
font_size : "13px",
font_family : "Arial"
};//容器样式
var containerConfig =
{
width : "100%",
height : "100%",
overflow : "auto",
padding : "10px",
backGround : "#ADC9EB",
borderLeft : "solid 1 #47578A",
borderBottom : "solid 1 #47578A",
borderRight : "solid 1 #47578A",
borderTop : "solid 1 #47578A"
};//构建tabpage类
//pageId为构建的tabpage的id
//objName为创建的对象的名称,用来相应点击事件
//containerId,为最外层的div,用来盛放整个tabpage页面
//whichShow为哪一个page需要默认选中,注:第一个page为0
function TabPage(pageId,objName,containerId,whichShow)
{
this.tabPageId = pageId;
this.whichShow = whichShow?whichShow:0;
this.objName = objName;
this.divNumber = 0;
this.idPrefix = "tabPageTd_";
this.container = containerId;
this.all = [];
}//在tabpage里面增加page页的内容
TabPage.prototype.addPage = function(divId,tipName)
{
if(divId.indexOf("|") != -1 || tipName.indexOf("|") != -1)
return;
this.all[this.divNumber] = divId + "|" + tipName;
this.divNumber ++;
}//toString方法
TabPage.prototype.toString = function()
{
var tabContent = "";
tabContent += " <TABLE id=" + this.tabPageId
+ " height=" + tabPageFaceConfig.sideHeight
+ " style='font-size:" + tabPageFaceConfig.font_size
+ "; font-family:" + tabPageFaceConfig.font_family + ";'"
+ " border=\"0\" cellpadding=\"0\" cellspacing=\"0\" onselectstart='return false;'>";
tabContent += "<tr style='cursor:hand' oncontextmenu = 'return false;'>";
for(var i=0; i<this.all.length; i++)
{
if(i == this.whichShow)
{
tabContent += " <TD id=" + this.idPrefix + this.all[i].split("|")[0]
+ " width=" + tabPageFaceConfig.imageLeftWidth
+ " height=" + tabPageFaceConfig.imageLeftHeight
+ " style ='color=red;background-image:" + tabPageFaceConfig.pressLeft
+ "' onClick=\"" + this.objName + ".toggleTabPage();\"></TD>";
tabContent += " <TD id=" + this.idPrefix + this.all[i].split("|")[0]
+ " width=" + tabPageFaceConfig.pageWidth
+ " style ='color=red;background-image:" + tabPageFaceConfig.pressMiddle
+ "' align=\"center\" onClick=\"" + this.objName + ".toggleTabPage();\">"
+ this.all[i].split("|")[1] + "</TD>";
tabContent += " <TD id=" + this.idPrefix + this.all[i].split("|")[0]
+ " width=" + tabPageFaceConfig.imageRightWidth
+ " height=" + tabPageFaceConfig.imageRightHeight
+ " style ='color=red;background-image:" + tabPageFaceConfig.pressRight
+ "' onClick=\"" + this.objName + ".toggleTabPage();\"></TD>";
}
else
{
tabContent += " <TD id=" + this.idPrefix + this.all[i].split("|")[0]
+ " width=" + tabPageFaceConfig.imageLeftWidth
+ " height=" + tabPageFaceConfig.imageLeftHeight
+ " style ='color=black;background-image:" + tabPageFaceConfig.normalLeft
+ "' onClick=\"" + this.objName + ".toggleTabPage();\"></TD>";
tabContent += " <TD id=" + this.idPrefix + this.all[i].split("|")[0]
+ " width=" + tabPageFaceConfig.pageWidth
+ " style ='color=black;background-image:" + tabPageFaceConfig.normalMiddle
+ "' align=\"center\" onClick=\"" + this.objName + ".toggleTabPage();\">"
+ this.all[i].split("|")[1] + "</TD>";
tabContent += " <TD id=" + this.idPrefix + this.all[i].split("|")[0]
+ " width=" + tabPageFaceConfig.imageRightWidth
+ " height=" + tabPageFaceConfig.imageRightHeight
+ " style ='color=black;background-image:" + tabPageFaceConfig.normalRight
+ "' onClick=\"" + this.objName + ".toggleTabPage();\"></TD>";
}
}
tabContent += "</tr>";
tabContent += "</table>";
return tabContent;
}//TabPage中隐藏所有内容层,默认选中的例外
TabPage.prototype.completed = function()
{
for(var i=0; i<this.all.length; i++)
{
if(i == this.whichShow)
document.all(this.all[i].split("|")[0]).style.display = "";
else
document.all(this.all[i].split("|")[0]).style.display = "none";
}
var oContainer = document.all(this.container);
oContainer.style.width = containerConfig.width;
oContainer.style.height = containerConfig.height;
oContainer.style.borderLeft = containerConfig.borderLeft;
oContainer.style.borderBottom = containerConfig.borderBottom;
oContainer.style.borderRight = containerConfig.borderRight;
oContainer.style.borderTop = containerConfig.borderTop;
oContainer.style.overflow = containerConfig.overflow;
oContainer.style.padding = containerConfig.padding;
oContainer.style.backgroundColor = containerConfig.backGround;
}
//TabPage中隐藏所有内容层
TabPage.prototype.hideAllDiv = function()
{
for(var i=0; i<this.all.length; i++)
document.all(this.all[i].split("|")[0]).style.display = "none";
}//page的点击事件
TabPage.prototype.toggleTabPage = function()
{
var oTable = document.all(this.tabPageId);
for(var i=0; i<oTable.rows[0].cells.length/3; i++)
{
var pageId = this.idPrefix + this.all[i].split("|")[0];
document.all(pageId)[0].width = tabPageFaceConfig.imageLeftWidth;
document.all(pageId)[0].height = tabPageFaceConfig.imageLeftHeight;
document.all(pageId)[0].style.backgroundImage = tabPageFaceConfig.normalLeft;
document.all(pageId)[1].width = tabPageFaceConfig.pageWidth;
document.all(pageId)[1].style.backgroundImage = tabPageFaceConfig.normalMiddle;
document.all(pageId)[2].width = tabPageFaceConfig.imageRightWidth;
document.all(pageId)[2].height = tabPageFaceConfig.imageRightHeight;
document.all(pageId)[2].style.backgroundImage = tabPageFaceConfig.normalRight;
document.all(pageId)[0].style.color="black";
document.all(pageId)[1].style.color="black";
document.all(pageId)[2].style.color="black";
}
if(event.srcElement.tagName.toLowerCase() == "td")
{
var srcObjectId = event.srcElement.id.substring(10);
var oPages = document.all(this.idPrefix + srcObjectId);
oPages[0].width = tabPageFaceConfig.imageLeftWidth;
oPages[0].height = tabPageFaceConfig.imageLeftHeight;
oPages[0].style.backgroundImage = tabPageFaceConfig.pressLeft;
oPages[1].width = tabPageFaceConfig.pageWidth;
oPages[1].style.backgroundImage = tabPageFaceConfig.pressMiddle;
oPages[2].width = tabPageFaceConfig.imageRightWidth;
oPages[2].height = tabPageFaceConfig.imageRightHeight;
oPages[2].style.backgroundImage = tabPageFaceConfig.pressRight;
oPages[0].style.color="red";
oPages[1].style.color="red";
oPages[2].style.color="red";
this.hideAllDiv();
document.all(srcObjectId).style.display = "";
tabPageProxy(srcObjectId);
}
else
return;
}//added by liu_xc 2004.6.15
//tabpage 单击代理
function tabPageProxy(pageId)
{}
//end-->
<HEAD>
<SCRIPT language="javascript" src="tabPage.js"></SCRIPT>
</HEAD>
<BODY>
<script language='javascript' defer>
var tab=new TabPage('firstTab','tab','tabPageContainer');
var arrayDiv=document.all;
document.all.cc1.value=document.documentElement.innerHTML
for(i=0;i <arrayDiv.length;i++){
var dId=arrayDiv[i].id.toString();
var dTitle=arrayDiv[i].title.toString();
alert("dTitle="+dTitle);
if(dTitle=='年度目标值数据采集'){
alert(1);
tab.addPage(dId,dTitle);
}
}
//document.write(tab);
</script> <DIV id="tabPageContainer">
<DIV id="div1" align="center" title="采集模板生成" style="display=none">
<TABLE width="80%" height="80%" bordercolor="#9966CC"
style="border:1px solid #9966CC">
<TR>
<TH scope="col">
asdasasdd
</TH>
<TH scope="col">
asdasd
</TH>
<TH scope="col">
asdasd
</TH>
<TH scope="col">
asdasdasdas
</TH>
</TR>
<TR>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
</TR>
<TR>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
</TR>
<TR>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
<TD>
asd
</TD>
</TR>
</TABLE>
</DIV>
<DIV id="div2" align="center" valign="middle" title="年度目标值数据采集" style="display=none">
<FORM>
<INPUT type="text" value="welcome to tabpage!" id="page2_in"
style="border:1px solid black">
<INPUT type="button" value="clickMe"
style="border:1px solid black; background-color:white">
</FORM>
</DIV>
<DIV id="div3" align="center" title="每月完成值数据采集" style="display=none">
<IMG src="/WebRootElec/image/es/tab/27.jpg" width="300" height="300">
<input type="button" name="btn" value="提交" onClick="" />
</DIV>
</DIV>
<textarea id="cc1" name='cc1' style="width:500px;height:300px">
</textarea>
<SCRIPT language="javascript" defer>
tab.completed();
</SCRIPT>
</BODY>
</HTML>
看一下是不是这样,在script标签中加入defer属性