Internet Explorer 6,7,8上的javascript错误,“是null或不是对象“ [英] javascript error on internet explorer 6,7,8, " is null or not an object "

查看:181
本文介绍了Internet Explorer 6,7,8上的javascript错误,“是null或不是对象“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动index.php时,它调用我的javascript文件,该文件包含以下代码:

when I start my index.php it calls my javascript file that has this code below:

当应用程序立即启动时出现此错误:

when the application starts immediately this error appears:

这只能发生在互联网浏览器上,index.php上没有'txtName',因为。每个页面调用js,有什么方法可以改进这个功能吗? tath我不需要手动将js放在每一页中吗?

and this can only happen on the internet explorers, there is no 'txtName' on index.php, because the. js is called for every page, there any way to improve this function ? tath i dont need to put manually the js in each page?

任何人都知道如何解决这个问题?非常感谢...

Anyone know how can I solve this ? Thank you very much...

推荐答案

为什么不为此方法设置条件:
在这种情况下:

Why dont you put a conditional for this method: In this case:

var iId = document.getElementById('txtName');
if(iId != null)
{
   // Processing
}

这篇关于Internet Explorer 6,7,8上的javascript错误,“是null或不是对象“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆