I load some .js dynamically by creating a script tag and writing javascript to the .innerHTML of it.
I get this error:
SCRIPT1004: Expected ';'
develop, line 1487 character 24
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 usually reports the correct line but it is always off by 1 line. I assumed IE9 would as well…
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.
Flying blind on IE9 pretty much.
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 );
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 );
}
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.
See: https://stackoverflow.com/a/9246128/1220302