运行下面的代码时,我的开发人员屏幕中出现错误,当您调用时在 php 页面中,或者 javascript 应该在消息旁边放置一个图标。在 IE 中它工作正常,但在 Chrome 和其他浏览器中得到:
Uncaught TypeError: object is not a function jsfunctions.php:92
dowarnerr jsfunctions.php:92
AddIcons jsfunctions.php:180
(anonymous function)
任何想法这是什么,为什么?
------------------------------------jsfunctions.php---------- -------------
function AddIcons()
{
if (typeof(error)=='object')
{
dowarnerr(error,'Error');
}
if (typeof(warning)=='object')
{
dowarnerr(warning,'Warning');
}
}
function doerror(err, etype)
{
msg = err.innerHTML;
if (etype=='Error') {
err.innerHTML = '<img id=icon src=/images/err.gif>' + msg;
}
else {
err.innerHTML = '<img id=icon src=/images/warning.gif>' + msg;
}
}
function dowarnerr(obj, etype)
{
if(typeof(obj.innerHTML) == 'string') {
doerror(obj, etype);
}
else
{
for (i = 0; i < obj.length; i++) {
doerror(obj(i), etype);
}
}
}
------------------------------------menu_config.php----------------------------------
<HEAD>
<LINK REL="StyleSheet" TYPE="text/css" HREF="/styles.php"></LINK>
<script language="JavaScript" src="/scripts/jsfunctions.php"></script>
</HEAD>
<SCRIPT LANGUAGE="javascript">
AddIcons();
</SCRIPT>