IE9报告存在缺少的分号 [英] IE9 reports missing semicolon that exists

查看:455
本文介绍了IE9报告存在缺少的分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过创建脚本标记并将javascript写入.innerHTML来动态加载一些.js。

I load some .js dynamically by creating a script tag and writing javascript to the .innerHTML of it.

我收到此错误:

SCRIPT1004: Expected ';' 
develop, line 1487 character 24

这没有任何意义......所以我猜它是正确或错误地报告行号(我至少很高兴它在失败...... 1487接近我的代码结束。)

This makes no sense...so I'm guessing it is reporting the line number correctly or wrong all together (I'm at least happy it made it this far with out failing out....1487 is near the end of my code ).

Firefox通常会报告正确的行,但总是偏离1行。我假设IE9也会...

Firefox usually reports the correct line but it is always off by 1 line. I assumed IE9 would as well...

我该如何排除故障。我已经验证了代码通过jshint.com,这使得它更加奇怪,它期待; 。如果它是真的,Jshint会抓住这个。

How can I troubleshoot. I already verified the code passes jshint.com which makes it even more strange that it is expecting a ;. Jshint would have caught this if it was real.

在IE9上飞行盲目。

这是代码:上面有10行,下面是10行。第1487行被注释为。

Here is the code: w/ 10 lines above and 10 line below. Line 1487 is commented as such.

    /**
     *Publik
     */

    var publik = {};
    publik.initMenu = function( )
    {
        top_element = document.getElementById( 'top_new' ); 
        bottom_element = document.getElementById( 'wrap_drop_down_new' );
        top_element.addEventListener( "mouseout", mouse_out, false ); 
        top_element.addEventListener( "mouseover", top_mouse_over, false ); // Line 1487
        bottom_element.addEventListener( "mouseout", mouse_out, false ); 
        bottom_element.addEventListener( "mouseover", bottom_mouse_over, false ); 
    };
    return publik;

}());
/*  Use this to create Event on completion of .js and remove cStart().

    var event_load_js = document.createEvent("HTMLEvents");
    event_load_js.initEvent( "blur", true, false );

每次Beat请求代码包含top_mouse_over

Code containig top_mouse_over per request of Beat

/**
 *MMenu
 */

var MMenu = ( function () 
{
    /**
     *Private
     */

    var top_element,
        bottom_element,
        time_out_id = 0,
        TIME_DELAY = 1000;

    function showBottom()
    {
        top_element.style.border = '1px solid #cfcaca';
        top_element.style.borderBottom = '3px solid #cfcaca';
        bottom_element.style.visibility = 'visible';
    }
    function hideBottom()
    {
        top_element.style.border = '1px solid #faf7f7';
        bottom_element.style.visibility = 'hidden';
    }
    function top_mouse_over()
    {
        window.clearTimeout( time_out_id );
        showBottom();
    }
    function bottom_mouse_over()
    {
        window.clearTimeout( time_out_id );
    }
    function mouse_out()
    {
        time_out_id = window.setTimeout( hideBottom, TIME_DELAY );
    }


推荐答案

复制动态生成的代码浏览器并将其粘贴到Notepad ++中并搜索?看看你是否有任何unicode字符。我很确定控制台没有说实话。我之前也遇到过这种情况。

Copy your dynamically generated code from the browser and paste it into Notepad++ and search for "?" to see if you have any unicode characters. I'm pretty sure that the console isn't telling the truth. I've ran into this before as well.

请参阅: https:/ /stackoverflow.com/a/9246128/1220302

这篇关于IE9报告存在缺少的分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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