javascript兼容性问题

来源:百度知道 编辑:UC知道 时间:2024/05/30 15:20:53
代码:
<script language="javascript">

function NoTextValue(str,str1)
{
if (document.getElementById(str).value==str1)
{
document.getElementById(str).value="";
document.getElementById(str).style.color="#000000";
}
}

function TextValue(str,str1)
{
if (document.getElementById(str).value=="")
{
document.getElementById(str).value=str1;
document.getElementById(str).style.color="#999999";
}
}

</script>

<input type="text" name="KeyWords" id="KeyWords" onfocus="NoTextValue('KeyWords','请输入要搜索的产品名称');" onblur="TextValue('KeyWords','请输入要搜索的产品名称');" value="请输入要搜索的产品名称">

以上代码在FF浏览器中可以正常显示,但IE中却毫无反应.是怎么回事啊?SOS!!!
我用的是IE6.0,测试完全没反应啊!各位大大!
我确定没有关闭IE的什么东西,因为同样的代码,我在另一个页面也没问题!实在是不知

呵呵,这是跨浏览器的代码,怎么会通不过呢?如果通不过可能是你的浏览器有问题或者IE中关闭了JS.

胡说,IE7中还是能用的,不过微软现在的编程习惯是
<script type="text/javascript">
不是
<script language="javascript">
但后者也是支持的

IE7

Opera 9.64

Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1

测试全部通过。