Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
767 views
in Technique[技术] by (71.8m points)

javascript - "element.dispatchEvent is not a function" js error caught in firebug of FF3.0

i am getting the following error while loading my index page in FF3.0. Sorry, i am unable to paste the script here as it is 2030 lines of code.

element.dispatchEvent is not a function

On expansion it gives me below things,

fire()()prototype.js?1 (line 3972)

_methodized()()prototype.js?1 (line 246)

fireContentLoadedEvent()prototype.js?1 (line 4006)

[Break on this error] element.dispatchEvent(event);

element.dispatchEvent(event); is in line 3972 of prototype.js. I am including prototype.js along with 10s of other js files in my index page.

Has anybody came across this kind of error? Please somebody explain me why this error is showing up.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

are you using jquery and prototype on the same page by any chance?

If so, use jquery noConflict mode, otherwise you are overwriting prototypes $ function.

noConflict mode is activated by doing the following:

<script src="jquery.js"></script>
<script>jQuery.noConflict();</script>

Note: by doing this, the dollar sign variable no longer represents the jQuery object. To keep from rewriting all your jQuery code, you can use this little trick to create a dollar sign scope for jQuery:

jQuery(function ($) {
    // The dollar sign will equal jQuery in this scope
});

// Out here, the dollar sign still equals Prototype

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...