设为首页   |  加入收藏夹 快速导航:  热门文章  |  最新文章  |  梦想博客  
当前位置:编程之家 -> 文章频道 ->jquery 
站内搜索:  

window.execScript in IE fails when scripts include HTML comment tag

作者:佚名 来源:不详 整理日期:2008-06-24
Hi, list

I found a jQuery 1.2.1 bug which fails in IE(6|7).

jQuery.domManip calls evalScript and finally executes
window.execScript if the conditions match,
but window.execScript in IE fails when scripts include HTML comment
tag.

Traditional way of writing script tag is as below for browsers which
are not support script tag.
So jQuery should trim HTML comment tag before executing
window.execScript function.

<script type="text/javascript>
<!--
javascript code
//-->
</script>

I created the patch for this problem.

*** jquery-1.2.1.js     2007-09-18 15:17:06.000000000 +0900
--- myjquery-1.2.1.js   2007-09-20 18:18:37.000000000 +0900
***************
*** 490,496 ****
        // Evalulates a script in a global context
        // Evaluates Async. in Safari 2 :-(
        globalEval: function( data ) {
!               data = jQuery.trim( data );
                if ( data ) {
                        if ( window.execScript )
                                window.execScript( data );
--- 490,496 ----
        // Evalulates a script in a global context
        // Evaluates Async. in Safari 2 :-(
        globalEval: function( data ) {
!               data = jQuery.trim( data ).replace(/^<!--/,
"").replace(/-->$/, "");
                if ( data ) {
                        if ( window.execScript )
                                window.execScript( data );

best regards,
Shinji Furuya

Traditional way of writing script tag is as below for browsers which
are not support script tag.
So jQuery should trim HTML comment tag before executing
window.execScript function.