属性' addEvent'是null或undefined,不是Function对象

时间:2012-11-12 09:00:28

标签: javascript css javascript-events moodle curvycorners

我试图在IE7和8中为moodle添加圆形边框,我正在使用javascript curvycorners.js脚本来执行此操作。我在我的脚本中添加了以下代码: -

<html <?php echo $OUTPUT->htmlattributes() ?>>
<head>
    <title><?php echo $PAGE->title ?></title>
    <link rel="shortcut icon" href="<?php echo $OUTPUT->pix_url('favicon', 'theme')?>" />
    <meta name="description" content="<?php p(strip_tags(format_text($SITE->summary, FORMAT_HTML))) ?>" />
    <?php echo $OUTPUT->standard_head_html() ?>
    <script src="/curvycorners.src.js" type="text/javascript"></script>
</head>
<script type="text/JavaScript">
addEvent(window, 'load', initCorners);
function initCorners() {
var setting = {
tl: { radius: 10 },
tr: { radius: 10 },
antiAlias: true
}
curvyCorners(setting, ".navbar");
curvyCorners(setting, ".minicalendar");
curvyCorners(setting, ".block-region .block .header");
curvyCorners(setting, ".coursebox");
curvyCorners(setting, "#news_header");
}
</script>

然而,在IE7中我收到一个错误: - 在尝试运行脚本时,属性“addEvent”的值为null或未定义,而不是Function对象。

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

我猜你在谈论attachEvent(IE / Opera)或addEventListener(Chrome / Safari / Firefox):

attachEvent(window, 'onload', initCorners);     // IE/Opera
addEventListener(window, 'load', initCorners);  // Chrome/Firefox/Safari